OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   SAX and Locator

[ Lists Home | Date Index | Thread Index ]

I am new to XML so if this is a dumb question, please don't be too 
hard on me. 

Background: 
=========
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.

Question:
=======
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.

Thanks,

Jonathan Baxter





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS