[EMAIL PROTECTED] wrote on 11/17/2004 11:44:42 AM:

> > So, my new question is, what would be involved in dynamically
> > switching the ContentHandler attached to a SAX2 parser, so that
> > some portions of a document could be parsed into a DOM document,
> > and others handled by a custom implementation of ContentHandler.
> > Essentially I want to switch to a DOM builder when I encounter a
> > <Header> element, then switch back to my own ContentHandler
> > implementation once the Header element has been parsed.
>
> You should do this yourself within your own ContentHandler/LexicalHandler
> derivative, rather assume the parser can support switching its handlers
> while parsing.


While this may or may not currently work with Xerces-C, the ability to switch content handlers during a parse is guaranteed by SAX [1] which says: "Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately". You should be able to rely on this behaviour.

[1] http://www.saxproject.org/apidoc/org/xml/sax/XMLReader.html#setContentHandler(org.xml.sax.ContentHandler)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]

E-mail: [EMAIL PROTECTED]

Reply via email to