Thl Doctype Definition Statement

THL Toolbox > Developers' Zone > Web Development > Xml Markup in THL > Doctype Defintion Statement

Doctype Definition Statement in THL

All XML documents begin with an XML declaration, defining the version of XML and the encoding:

<?xml version="1.0" encoding="UTF-8"?>

This tells the program opening or rendering the file that it is an XML file encoded in Unicode, and is necessary for the proper interpretation of the file. Following this there is a Document Type Definition (DTD) statement. This defines the XML mark-up rules used in the document. (There are two ways to define the mark-up rules in an XML document through a DTD using DTD statement before the root element of the document or through a schema using a xsi:schemaLocation attribute on the root element. In THL we use the DTD statement.) The generic structure of the DTD statement is as follows (bracketed italic material is descriptive):

<!DOCTYPE {Root Element Name} SYSTEM "{relative or absolute location of the DTD}" [ 
    {entity declarations and other modifications or additions to the DTD}
]>

The first word after "DOCTYPE" must be the exact name of the root element of the XML document. This is the first ancestor-of-all element that encloses all the markup in the document. In an XHTML document this would be the <html> <./html> element which contains all the markup. For THL XML essays and catalogs it is the <TEI.2> … </TEI.2> element, but for individual catalog records (TIBBIBL, which stands for Tibetan Bibliographic record) it is the <tibbibl> … </tibbibl> element. The simplest form of the DTD found in THL is the catalog record DTD statement which is for independently validating TIBBIBL. It usually commented out, because the TIBBIBL is general found embeded in a larger TEI.2 document. An example is:

<!DOCTYPE tibbibl SYSTEM "http://texts.thlib.org/catalogs/xtibbibl3.dtd" >

At the very top of the XML file, in the second line, is the Doctype call. If you are not running localhost on your machine you need to use different Doctype calls when you are editing the file and when you commit the file to subversion. This calls an on-line version of the DTD at the external link: http://texts.thlib.org domain. Sometimes however validating a document using an online URL is not possible because one is not on-line or the connection is slow. In such cases it is more convenient to use a relative URL. This is the case for most of the XML documents in THL since the Cocoon web app THL uses to render our XML documents is at external link: http://texts.thlib.org it is quicker to refer to a relative URL than to route it through the absolute address. An example from a JIATS article which includes XML entities is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE TEI.2 SYSTEM "../../../xml/dtds/xtib3.dtd" [
  <!ENTITY % extlinks SYSTEM "../../../essays/xml/external-links.dtd" >
  %extlinks;
  <!ENTITY % intlinks SYSTEM "../../../essays/xml/internal-links.dtd" >
  %intlinks;
  <!ENTITY glossary SYSTEM "../glossaries/rej_akester-gloss.xml" >
]>

This uses the location of the DTD relative to the XML document and to this DTD includes entity definitions for links external to THL and internal THL links as well as a declaration of an XML entity containing the markup for the glossary to this article, a rejoinder by Akester.

For further information see:

Provided for unrestricted use by the external link: Tibetan and Himalayan Library