Other Types of Markup

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

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 DTDs 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.-->
  <name>Jim Jones</name> <!-- The client’s name -->
  <number>217-352-3717</number> <!-- The client’s number -->
<!-- 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 under Displaying MathML in web browsers and Applying styles and transformations.


<< back next >>





Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America