> 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. > 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. > 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 Dave --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]