[Home] [By Thread] [By Date] [Recent Entries]

  • To: xml-dev@l...
  • Subject: SAX and Locator
  • From: Jonathan Baxter <jbaxter@p...>
  • Date: Tue, 23 Jul 2002 12:30:32 +0930
  • Organization: Panscient
  • Reply-to: jbaxter@p...
  • User-agent: KMail/1.4.1

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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member