[jdom-interest] (no subject)

Laurent Bihanic laurent.bihanic at atosorigin.com
Mon Jul 22 08:47:02 PDT 2002


Hi,

SAX parser provide document locators (org.xml.sax.Locator) that keep this 
information up-to-date and can be queried by applications.

With JDOM, its a little bit more complicated: SAXHandler keeps a reference to 
the parser's Locator but SAXBuilder does not give public access to the 
SAXHandler instances as one of these is created for each parse.

Thus, the easiest way is to create your own builder by deriving from 
SAXBuilder that will keep a reference to the current SAXHandler and provide a 
method to return the information you are interested, relying on SAXHandler's 
getDocumentLocator().

Laurent


Adrian Jetzer wrote:
> Hi there!
>  
>  
> I'm parsing a xml-file. The file has a specific amount
> of elements.
>  
> Is there a way to know, on which line of the file 
> the parser in a particular moment is?
>  
> For example. After I read (parsed) several elements of
> the xml file, I would like to know, on which line
> of the file the "actual-file-pointer" is.
>  
> I don't want to know the line-number for every element.
> Just sometimes I want to check, on which line the
> parser is.
>  
>  
> For what do I use this?
>  
> I want to use it for a progress bar. I want to show the
> user how far the parsing process is. I know the total
> amount of lines in the file. So with some checkpoints
> (hey parser, on which line are you now?) I can  realise
> a progress bar ....
>  
> Adrian




More information about the jdom-interest mailing list