Java Reference
In-Depth Information
Here the namespace with the prefix print contains names for elements relating to hardcopy presentation
of sketch elements. The <circle> element in the print namespace is qualified by the namespace prefix so
it is distinguished from the element with the same name in the default namespace.
XML Namespaces and DTDs
For a document to be valid, you must have a DTD, and the document must be consistent with it. The way
in which a DTD is defined has no specific provision for namespaces. The DTD for a document that uses
namespaces must therefore define the elements and attributes using qualified names, and must also make
provision for the xmlns attribute, with or without its prefix, in the markup declaration for any element in
which it can appear. Because the markup declarations in a DTD have no specific provision for accommod-
ating namespaces, a DTD is a less than ideal vehicle for defining the rules for markup when namespaces are
used. The XML Schema specification provides a much better solution, and overcomes a number of other
problems associated with DTDs.
XML SCHEMAS
Because of the limitations of DTDs that I mentioned earlier, the W3C has developed the XML Schema lan-
guage for defining the content and structure of sets of XML documents, and this language is now a W3C
standard. You use the XML Schema Definition language to create descriptions of particular kinds of XML
documents in a similar manner to the way you use DTDs, and such descriptions are referred to as XML
Schemas and fulfill the same role as DTDs. The XML Schema language is itself defined in XML and is
therefore implicitly extensible to support new capabilities when necessary. Because the XML Schema lan-
guage enables you to specify the type and format of data within an XML document, it provides a way for
you to define and create XML documents that are inherently more precise, and therefore safer than docu-
ments described by a DTD.
It's easy to get confused when you are working with XML Schemas. One primary source of confusion
is the various levels of language definition you are involved with. At the top level, you have XML —
everything you are working with in this context is defined in XML. At the next level you have the XML
Schema Definition language — defined in XML, of course — and you use this language to define an XML
Schema, which is a specification for a set of XML documents. At the lowest level you define an XML doc-
ument — such as a document describing a Sketcher sketch — and this document is defined according to the
rules you have defined in your XML Schema for Sketcher documents. Figure 22-3 shows the relationships
between these various XML documents.
FIGURE 22-3
 
 
Search WWH ::




Custom Search