4.2. Document Type Declarations

An XML document refers to a DTD within an XML“<!DOCTYPE>” tag. The document type declaration can do either or both of the following:

  • Contain the markup declarations in an internal subset within the <!DOCTYPE> tag

  • Point to an external subset containing markup declarations

The document type declaration must appear before the first element in the document. Examples 4-1 and 4-2 provide samples of internal and external DTDs.

Example 4-1. Internal DTD
 <?xml version="1.0"?> <!DOCTYPE memo [ <!ELEMENT memo (to,from,subject,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT subject (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <memo> <to>Jon</to> <from>Chris</from> <subject>Reminder</subject> <body>Three PM meeting ...

Get Secure XML: The New Syntax for Signatures and Encryption now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.