2.3 Other Types of Markup

 < Day Day Up > 



2.3 Other Types of Markup

The document tree is where the bulk of the useful information in an XML document resides. However, some information (such as the XML declaration) appears outside the document tree as well. The XML declaration is a statement that identifies the document as being written in XML. It appears at the beginning of the document before the root element. An XML declaration is not required but it is a good practice to include one. Here is what a typical XML declaration looks like:

    <?xml version="1.0" encoding="US-ASCII"    standalone="yes"?> 

The XML declaration accepts the following three attributes. The first attribute is required while the other two are optional:

  • version-This specifies the version of XML the document conforms to. This attribute must always have the value 1.0 since that is the only version of XML currently defined. Other values may become possible if and when the W3C releases a later XML version.

  • standalone-This has the value no if the document references an external DTD and the value yes if the XML document does not refer to a DTD or refers to an internal DTD (that is, a DTD included in the document itself). See Section 2.4 for an explanation of DTDs.

  • encoding-This specifies the character encoding used for the text in the XML document. By default, the text in any XML document is assumed to be in the UTF-8 encoding of the Unicode character set. However, you can specify a different encoding scheme using this attribute.

Two other types of markup that can occur in an XML document are comments and processing instructions. These can occur either as part of an element's content or before or after the root element. However, they cannot appear inside a tag; that is, within the angled brackets containing the tag name.

Authors typically use comments to provide information about the document (such as the date it was last modified) or what changes were made to it. Any text that is enclosed by the delimiters <!- and -> is regarded as a comment and is ignored by XML processors. Here is an example:

     <?xml version="1.0"?>    <!-- The document tree starts here.-->      <client>        <name>Jim Jones</name> <!-- The client's name --    >       <number>217-352-3717</number>       <!-- The client's number -->     </client>    <!-- The document tree ends here.--> 

Processing instructions contain information that a processing application can use to decide how to handle specific parts of the XML document. One important use of processing instructions is for specifying a stylesheet to be used with the document. Here is an example:

    <?xml-stylesheet type="text/xsl"    href="http://www.w3.org/Math/XSL/mathml.xsl"?> 

The type attribute specifies the format of the stylesheet, while the href attribute gives its location, either as an absolute or relative Universal Resource Locator (URL). We'll see examples of using stylesheet-processing instructions with MathML documents in Chapters 7 and 8.



 < Day Day Up > 



The MathML Handbook
The MathML Handbook (Charles River Media Internet & Web Design)
ISBN: 1584502495
EAN: 2147483647
Year: 2003
Pages: 127
Authors: Pavi Sandhu

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net