Layering Schemas

When considering the schema language that's appropriate for your needs, the following questions may help you decide.

  • Do you need to constrain element and attribute structures? If so, choose DTDs, the W3C XML Schema Language, or RELAX NG.

  • Do you need to define entities? If so, you'll need a DTD.

  • Do you need broad compatibility with existing software and systems? Choose DTDs.

  • Do you need a simple, human-authorable syntax? Choose RELAX NG.

  • Do you need to annotate elements and attributes, either with types or other information? If so, the W3C XML Schema Language is powerful.

  • Do you need to store the schema documents independent of the instance documents? Choose the W3C XML Schema Language, Schematron, or RELAX NG.

  • Do you need co-occurrence or exclusion constraints? If so, Schematron is for you.

  • Does validation require access to data from outside the document, for example, in the file system or an external database? If so, you'll need to write a custom program in your language of choice to perform the validation, but you may be able to plug this into a RELAX NG validator.

Finally, remember that none of these needs are mutually exclusive. If you answered yes to several of these questions, you may want to apply multiple schemas to a single document in sequence.

Hammers are useful tools, but you wouldn't use one to cut wood. Use the right tool for the job. The W3C XML Schema Language is a useful tool, but it's not the only tool, and it doesn't fit all applications. DTDs still work very well for traditional narrative documents such as books, transcripts, and e-mail. Schematron can make assertions no other schema language can make. RELAX NG is much easier to learn and master than the W3C XML Schema Language. All carpenters have many tools in their toolboxes. You should have many schema languages in your XML toolbox.

Effective XML. 50 Specific Ways to Improve Your XML
Effective XML: 50 Specific Ways to Improve Your XML
ISBN: 0321150406
EAN: 2147483647
Year: 2002
Pages: 144 © 2008-2017.
If you may any questions please contact us: