Title: Getting the internal DTD
Hi Steen
 
Good idea.
 
I've patched the DocumentType so that getText() should return the text value of the internal DTD subset - in your example this would be "<!ELEMENT greeting (#PCDATA)>".
 
I've added 4 classes to the org.dom4j.dtd package to give a better understanding of the internal DTD subset, there's ElementDecl, AttributeDecl, InternalEntityDecl, ExternalEntityDecl. These declarations are available as a List on the DocumentType interface. These classes are experimental and not heavily tested yet - I'd appreciate any feedback you might have.
 
I've added a simple JUnit test case (org.dom4j.TestDocType) and added your example document to /xml/dtd/internal.xml. If you pass it into the SAXDemo you should get the same document back again. e.g.
 
    java SAXDemo xml/dtd/internal.xml
 
should parse and output the document correctly.
 
I've committed all this to CVS and its available in the daily build also.

James
----- Original Message -----
Sent: Wednesday, October 10, 2001 12:50 PM
Subject: [dom4j-user] Getting the internal DTD


Is there any way to access, through dom4j, the internal DTD declarations that may appear in a document?

Example (from the XML standard):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE greeting [
  <!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello, world!</greeting>

Getting the DocType only returns the system and public ids, it would be kind of useful if you could do getText() (or something similar) on DocType and get the internal DTD as a string.

Cheers,

-- Steen

/**
 * Steen Lehmann - <mailto:[EMAIL PROTECTED]>
 * Senior Software Engineer (R&D), SilverStream Software
 * <http://www.silverstream.com>
 */

Reply via email to