Create DOM from SAX stream

Discussion in 'XML' started by Collin VanDyck, Dec 8, 2004.

  1. 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
    Collin VanDyck, Dec 8, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Collin VanDyck

    Create DOM from SAX stream

    Collin VanDyck, Dec 8, 2004, in forum: Java
    Replies:
    1
    Views:
    509
    Alan Gutierrez
    Dec 9, 2004
  2. Xavier Seneque

    Parsing an XML stream with java ( sax )

    Xavier Seneque, Feb 23, 2005, in forum: Java
    Replies:
    2
    Views:
    10,657
    Xavier Seneque
    Feb 24, 2005
  3. Rogan Dawes

    HTML parser to DOM via SAX?

    Rogan Dawes, Mar 7, 2005, in forum: Java
    Replies:
    0
    Views:
    632
    Rogan Dawes
    Mar 7, 2005
  4. Nobody
    Replies:
    3
    Views:
    964
    Joseph Kesselman
    May 9, 2006
  5. moralbarometer
    Replies:
    8
    Views:
    514
    moralbarometer
    Mar 5, 2007
Loading...

Share This Page