untitled

(ff) #1

2.3 XML Schema 43


Figure 2.8 XML data model for the same molecule as in figure 2.7 except that the
two atoms have been reversed.


ple data types for specialized needs. For example, one could define a
DNA sequence to be text containing only the letters A, C, G, and T.

There is a tool written in Perl, calleddtd2xsd.pl(W3C 2001a) that trans-
lates DTDs to XML schemas. However, one must be cautious when using
this tool. It does not support all of the features of XML. For example, con-
ditional sections are not supported. As one of the authors pointed out, “It
is worth pointing out that this tool does not produce terribly high quality
schemas, but it is a decent starting point if you have existing DTDs.” When
one is using this tool one must manually check that the translation is correct.
One can then enhance the schema to improve the semantics using features of
XSD that are not available in DTDs.
Applying thedtd2xsd.plprogram to figure 2.2 gives the XML schema
shown below. The XML schema is considerably longer than the DTD. We
leave it as an exercise to do the same for the molecule DTD in figure 1.6.


<schema
xmlns=’http://www.w3.org/2000/10/XMLSchema
targetNamespace=’http://www.w3.org/namespace/
xmlns:t=’http://www.w3.org/namespace/’>


<element name=’MedlineCitation’>
Free download pdf