Book HomeXML SchemaSearch this book

14.4. XML 1.0 Comments

There is a general tendency among recent XML vocabularies to use special elements to add documentation or meta-information rather than general purpose XML 1.0 comments or processing instructions. W3C XML Schema follow this tendency with its xs:documentation and xs:appinfo elements. The arguments often used to justify this choice are the ease of use by applications and the fact that parsers are not obliged to transmit comments to applications. In practice, most parsers do transmit comments; comments are available to the applications and can be manipulated quite easily, even through XPath expressions. A more solid argument in favor of using elements is their ability to include structured content.

On the other hand, XML 1.0 comments (and processing instructions) are lighter weight and can be included at any location within any element--not only as the first child element of XML Schema components. With an XML 1.0 comment, our example becomes:

<xs:element name="author" type="author">
  <!-- This element describes the author of a book. -->
</xs:element>


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.