Datasheet

Using SYSTEM as shown allows the parser to load the DTD from the specified location. If you use PUBLIC,
the named DTD should be one that is familiar to the parser being used, which may have a store of
commonly used DTDs. In most cases, you will want to use your own DTD and use SYSTEM. This method
enables the parsing application to make its own decisions as to what DTD to use, which may result in a
performance increase; however, specific implementation of this is down to individual parsers, which might
limit the usefulness of this technique.
Because of the inherent disadvantages of DTDs, XML Schemas are the commonly used mechanism to
validate XML documents. XML schemas are discussed in detail in a later section of this chapter.
XDR
XML Data Reduced (XDR) schema is Microsoft’s own version of the W3C’s early 1999 work-in-progress
version of XSD. This schema is based on the W3C Recommendation of the XML-Data Note (
http://www
.w3.org/TR/1998/NOTE-XML-data
), which defines the XML Data Reduced schema.
The following document contains the same information that you could find in a DTD. The main difference
is that it has the structure of a well-formed XML document. This example shows the same constraints as
the DTD example, but in an XML schema format:
<?xml version=”1.0” ? >
<!-- XML-Data is a standalone valid document-->
<Schema xmlns=”urn:schemas-microsoft-com:xml-data”>
<AttributeType name=”author” required=”yes”/>
<AttributeType name=”id” required=”yes”/>
<ElementType name=”title” content=”textOnly”/>
<ElementType name=”chapter” content=”textOnly”/>
<ElementType name=”book” content=”eltOnly”>
<attribute type=”author” />
<element type=”title” />
<element type=”chapter” />
</ElementType>
</Schema>
There are a few things that an XDR schema can do that a DTD cannot. You can directly add data types,
range checking, and external references called namespaces.
As useful as DTDs are, they also have their shortcomings. The major concern most
developers have with DTDs is the lack of strong type-checking. Also, DTDs are
created using a strange and seemingly archaic syntax. They have only a limited
capability in describing the document structure in terms of how many elements can
nest within other elements.
13
Introduction to XML
04_596772 ch01.qxd 12/13/05 11:17 PM Page 13