Create DOM from SAX stream

C

Collin VanDyck

I'm sorry if this has been incredibly overdone; I googled for a couple
minutes and couldn't come up with a definitive answer.

In my application I have the need to create a DOM from a stream of SAX
events. The way it currently works is that I instantiate an
org.apache.xml.utils.DOMBuilder on an empty org.w3c.dom.Document that
I've created from a JAXP DocumentBuilderFactory.

For the most part it works fine; all of the ContentHandler callbacks get
reported into the Document but only some of the LexicalHandler events
get reported.

Looking into the source for DOMBuilder I see that it tends to ignore
certain lexical events, mainly startDTD():

/**
* Report the start of DTD declarations, if any.
*
* Any declarations are assumed to be in the internal subset
* unless otherwise indicated.
*
* @param name The document type name.
* @param publicId The declared public identifier for the
* external DTD subset, or null if none was declared.
* @param systemId The declared system identifier for the
* external DTD subset, or null if none was declared.
* @see #endDTD
* @see #startEntity
*/
public void startDTD(String name, String publicId, String systemId)
throws org.xml.sax.SAXException
{

// Do nothing for now.
}


The DOMBuilder I'm using comes from the rt.jar under the 1.4.2_03 SDK.

I need these events to be fed back into the Document. Am I missing
something obvious here or will I need to extend the DOMBuilder and fill
in the gaps? Seems strange to me that would be left out.

Thanks for any help
Collin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top