Document Type Declarations

Documents created with JDOM can have document type declarations and thus can be valid. JDOM does not offer a complete object model for DTDs, but it does allow you to point at an existing DTD or add an internal DTD subset to your documents.

Example 14.2 is a simple document type definition (DTD) for the Fibonacci number documents we've been generating.

Example 14.2. A Fibonacci DTD
<!ELEMENT Fibonacci_Numbers (fibonacci*)>
<!ELEMENT fibonacci (#PCDATA)>
<!ATTLIST fibonacci index CDATA #IMPLIED>

Let's assume that this is available at the relative URL fibonacci.dtd. Thus the following DOCTYPE declaration would make the document valid:

<!DOCTYPE Fibonacci_Numbers SYSTEM "fibonacci.dtd"> 

In JDOM, the DocType class represents ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX 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.