Hi As far as I know (about 4 month since I gave up JDom) they don't support it.
Here is the last mail in the thread about line numbering ... look in the mail archive for more info. ************* Hi Nicholas This sounds great. Fancy submitting it then we can add this to the dom4j distribution? James ----- Original Message ----- From: "Nicholas Sanderson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 08, 2002 10:50 PM Subject: [dom4j-user] re Collecting line numbers > Hi > > I saw the post about collecting line numbers. I managed this in pretty much > the way you suggested. > > Extend SAXReader and override the setContentHandler method to return a > customised SAXContentHandler(see below). > > Call SAXReader passing in a UserDataDocumentFactory > > I extended SAXContentHandler adding a document locator the > setDocumentLocator and overriding the start element method. > > I also overloaded the constructor that takes a DocumentFactory and a > DispatchHandler, simply > making a call to the superclass constructor with the same arguments. > > In the start element method I called the superclass startElement and then > got the current Element from the Element stack. This was a pain because > ElementStack has only package visibility so I had to put my Handler in the > same package- org.dom4j.io. Once you've got the stack it's easy - cast the > Element returned from stack.getCurrent() to be a UserDataElement > and call setData - I was lazy and just called e.setData(new > Integer(loc.loc.getLineNumber())) - where loc is the document locator. > > > To create the decorated tree - I was validating the document as well > > SAXReader xmlReader = new > SpecialXMLReader(UserDataDocumentFactory.getInstance(), true); > this.doc = xmlReader.read(aFile); > > Any elements in this tree can be cast to UserDataElements and then getData > will return an Integer that reprsents the line that it occurs on - depending > upon the vagaries of the locator object. > > I hope this is helpful. > > Nick > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user ************* > -----Ursprungligt meddelande----- > Från: Donald Ball [mailto:[EMAIL PROTECTED]] > Skickat: den 5 juni 2002 00:47 > Till: dom4j > Ämne: Re: [dom4j-user] given a Node, can i get its original position > information? > > > On Tue, 2002-06-04 at 13:38, James Strachan wrote: > > Right now no. Someone was looking at implementing something > like this; maybe > > using the UserDataDocumentFactory to create UserDataElement > instances which > > could have some location information associated with each > element. By > > deriving from SAXReader it should be possible to do this. > > do you happen to remember who or have a link to or search term for the > earlier discussion? > > it would seem using the UserData stuff wouldn't fully address the > situation since one may well want to know location > information for text > nodes and maybe even comments for the purpose of spell > checking and the > like. the UserData stuff seems to be limited to attributes > and elements? > > might it instead be appropriate to add an api to Node for getting that > information, provide a default -1 implementation, and to provide a > method for SAXReader (and SAXContentHandler?) for turning it on if > desired? i understand that most dom4j users don't care about position > information, but for those that do, this would be _much_ easier than > having to deal with sax input manually. and isn't that the point of > dom4j anyway, to provide a sane, useful api for working with xml in > java? :) > > is anyone else interested and able to work on this in the nearish > future? > > finally, just to check - does anyone know if jdom supports this > functionality? > > - donald > > _______________________________________________________________ > > Don't miss the 2002 Sprint PCS Application Developer's Conference > August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user > _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user