Lists Home |
Date Index |
I am new to XML so if this is a dumb question, please don't be too
hard on me.
I am using SAX to parse HTML that has been "tidied" (I am using JTidy
and also experimenting with NekoHTML).
I need to know exactly where in the original document certain SAX
events originate, so I am using the Locator mechanism.
Locator measures the origin of SAX events by line number and column
number. Apart from the hassle of having to keep track of line numbers
in the original document as the parse progresses, it is "lossy" to
communicate event locations just by line number and column number,
since events are generally the result of processing a range of
characters in the original document.
Would it be possible to have Locator return the starting character
offset and the ending character offset of the sequence of characters
that generated the SAX event? For example, after a tag is processed,
within the corresponding startElement(...) callback a call to
Locator.getStartCharacter() would return the location of the "<" at
the start of the tag and a call to Locator.getEndCharacter() would
return the location of the ">" at the end. The location would simply
be the index of the characters within the original stream.