Java Reference
In-Depth Information
<!ELEMENT BookType (#PCDATA)>
<!ELEMENT Price (#PCDATA)>
<!ENTITY HARDCOVER "Hardcover">
<!ENTITY PAPERBACK "Paperback">
The first statement in this DTD describes an XML element whose name is
Order . According to this DTD, an Order consists of one or more LineItem elements
(represented by the (LineItem)+ expression in the example). The Order must be fur-
ther described using the attribute named orderNumber . An orderNumber attribute
can contain any valid character sequence (as specified by the CDATA type). It is a
required attribute, as specified by the #REQUIRED flag.
A LineItem , in turn, consists of a Title , one or more Authors (as indicated by
the command Author+ ), a BookType , and a Price, all in the specified sequence given.
These subelements are all user-defined data types, which can contain any character
sequence (#PCDATA).
The last section of the DTD declares two internal entities (similar to macros)
named HARDCOVER and PAPERBACK. These internal entities are assigned the
String values " Hardcover " and " Paperback" , respectively.
A DTD not only provides the structural information required to properly parse
the document, it allows the parser to examine the document for completeness and
document integrity. It is similar in nature (although limited in features) to the
Structured Query Languages' (SQL's) Data Definition Language (DDL) statements.
If a DTD specifies that certain elements are required, then these elements must be
present in the document. Conversely, only properly identified elements are allowed
in an XML document.
An input parser application can quickly scan XML documents to validate that
they match their required structure, independent of any data or content validation.
An XML document can be independently checked to make sure it is both well formed
(it conforms to proper generic XML syntax) and valid (it conforms to its DTD).
An XML document can either contain its DTD (that is, as the initial part of the
document) or simply refer to it as an external file. Either a URL or a local file name
can be referenced as the DTD repository. External file references work much the
same way that COPY statements work in COBOL. External file references are pre-
ferred, since their use conserves bandwidth and provides a standard location for the
most recent specification.
DTD C OMPONENTS
A DTD describes these optional XML document components in any combination:
elements, attributes, and entities.
Search WWH ::




Custom Search