You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Born Franz <Fr...@blr.spcnl.co.in> on 2000/01/30 18:03:12 UTC

Is DTD-info not stored during parsing?

1.0.1 on WinNT

When I start DOMPrint on the samples\data\personal.xml in the output the
line regarding the DTD is missing. 

<?xml version="1.0" encoding="ASCII"?>
<!DOCTYPE personnel SYSTEM "personal.dtd">   <-- missing

<!-- @version: -->


--------

I added some lines where the output should start (around 240)

    // If the parse was successful, output the document data from the DOM
tree
    if (!errorsOccured)
    {

//      DOM_Node doc = parser.getDocument();

		// start insert
                        DOM_Document doc = parser.getDocument();
		DOM_DocumentType
			docType = doc.getDoctype(); // here fImpl => 0
		DOMString
			dtdName = docType.getName();

		cout << dtdName << endl;
		// end insert

		cout << doc << endl;
    }

But it doesn't work, as the getDoctype() returns a fImpl which is 0.

Am I making an error or is there a bug?



Best regards

Franz

     \|/
     o o
--^^-(_)-^^---------------

Franz W. E. Born                Tel..: +(91) 80 / 50 62 21 6
                                SCS..: -3216
                                EMail: franz.born@blr.spcnl.co.in
SCS A10                         DU4-38




Re: Is DTD-info not stored during parsing?

Posted by Andy Clark <an...@apache.org>.
Born Franz wrote:
> When I start DOMPrint on the samples\data\personal.xml in the output the
> line regarding the DTD is missing.
> 
> <?xml version="1.0" encoding="ASCII"?>
> <!DOCTYPE personnel SYSTEM "personal.dtd">   <-- missing

You're not missing anything -- it doesn't print the DTD. While
our implementation has getSystemId() and getPublicId(), these
methods only come into use in DOM Level 2. When those samples
were written, those methods didn't exist on the DocumentType
node, if I remember correctly.

To enable this, we must either assume that the DOM wrapper
used to parse the document is DOM 2 compliant, or use Java
reflection to see if those methods exist on the implementation
and then call them. We do the latter on the XML serializers
implementation in order to write the DOCTYPE line.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org