XML technologies / XML Schema / Documenting schemas / Which one, and for what?
(Excerpt from “XML Schema” by Eric van der Vlist)
Reviewing the three ways to add simple comments, we can use xs:documentation:
<xs:element name="author" type="authorType">
<xs:annotation>
<xs:documentation xml:lang="en">The author of a book.</xs:documentation>
<xs:documentation xml:lang="de">Der Autor eines Buches.</xs:documentation>
<xs:documentation xml:lang="fr">Designe l'auteur d'un livre.</xs:documentation>
</xs:annotation>
</xs:element>or foreign attributes:
<xs:element name="author" type="authorType" doc:doc="Dieses Element beschreibt den Autor eines Buches." xmlns:doc="http://dyomedea.com/ns/doc"/>or XML 1.0 comments:
<xs:element name="author" type="authorType">
<!-- Dieses Element beschreibt den Autor eines Buches. -->
</xs:element>Which is best? There is no simple answer: it depends on tool support and what you want to do with the comments. But does it really matter? The hard work is writing meaningful comments and keeping them current. The format itself matters little, and each approach is only one XSLT transformation away from the other two.
The same applies to all schema metadata discussed here: it leaves the schema intact and processable by every schema processor, although most ignore it. Adding it makes sense only with an application in mind; application constraints determine the format.
Finally, we have presented only schema-centered options, adding information within W3C XML Schema conforming to the recommendation. Other options center on object-oriented design, generating schemas from UML specifications, or adjuncts, describing a schema adjunct outside the W3C XML Schema document. Inventive packaging could also group resources, schemas, transformations and stylesheets for one information unit under a common umbrella, rearranging traditional function-based packages to suit the application’s structure.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de
back to top