[EMAIL PROTECTED] wrote:
I've been experimenting with using SAX2XMLReader::getSrcOffset()
to find the file position that elements were found at. The problem
with getSrcOffset() is that it doesn't always correspond exactly
to the absolute file position, as (for example) XMLReader will
sometimes silently eat the LF portion of a CR/LF pair, only adding
1 to the offset count rather than 2.


Sometimes? I would expect this would always happen, because of whitespace normalization.

I had always seen the LF being eaten as you say, but I thought I'd say "sometimes" to cover myself - I'm fairly new to XML processing and very new to Xerces. Sorry if I caused any confusion.




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.


Is there any documentation available on how to build a DOM document from a SAX/SAX2 source? I looked at installing a XercesDOMParser into my SAX2XMLReader with SAX2XMLReader::installAdvDocHandler(...), but of course the XercesDOMParse isn't initialized correctly. I'm assuming that I shouldn't be using XercesDOMParser to directly receive the SAX2 events. Do I need to roll my own bridge, or is there any existing implementation available?



Does anyone have any advice, or references to any relevent

documentation?

What you're describing sounds like what SAX calls "filtering":

http://www.saxproject.org/?selected=filters


From what I can see, Xerces-c doesn't implement the org.xml.sax.XMLFilter interface, or XMLFilterImpl, right? Does anyone know if support for filtering will be available any time soon?


Thanks for your help,

Pete

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to