I read the mail as follows but i still don't know how to do it. could
someone give me a demo or an example. Thank you very much.
> Hi Dhanji,
> you can override org.dom4j.DocumentFactory and you can insert yout own
> Locator2 (with setDocumentLocator() method) into
> org.dom4j.io.SAXContentHandler, so you can obtain location information
> from your Locator. Than you can read the location information from
> supplied Locator in DocumentFactory and write down this info at newly
> created node �C into some Map, or you can override DefaultElement,
> DefaultAttribute and so on and write location information to your
> overriden instances of these classes.
>
> There is no way how to obtain the location information from DOM4J
> without overriding classes, because DOM representation of XML has no
> relationship with XML in file with lines and columns, so it doesn't
> make sense to store this information somewhere in DOM4J standard
> classes.
>
> Somethink like this:
>
> org.xml.sax.Locator locator = new …;
> DocumentFactory documentFactory = new DocumentFactoryWithLocator(locator);
> SAXContentHandler contentHandler = new SAXContentHandler(documentFactory
);
> contentHandler.setDocumentLocator(locator);
>
>
> org.xml.sax.XMLReader reader = …;
>
> reader.setContentHandler(contentHandler );
> reader.parse(…);
>
> Document document = contentHandler.getDocument();
>
> In DocumentFactoryWithLocator you will have methods like this:
>
> public Element createElement(QName qname) {
> ElementWithLocation element = new ElementWithLocation (qname);
> element.setLocation(locator.getLineNumber(),
> locator.getColumnNumber());
> return element;
> }
>
> And so on…
Filip Jirsák
>
> 2008/8/23 Dhanji R. Prasanna <[EMAIL PROTECTED]>:
> > Hi,
> > First, dom4j is great.
> > Second, I am using SAX parsing and would like to obtain document line
> number
> > information associated with dom4j Elements (or Nodes). Is this possible?
> > What's the best way to go about it?
> > I tried searching the list but didnt turn up much. Any help is
> appreciated.
> > Thanks!
> > Dhanji.
> >
-------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> > prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user