i've done some initial work on this and it seems pretty easy to do, actually. i patched SAXContentHandler to store the Locator instance if it gets one and to store the position information when it creates new elements. strictly proof of concept, of course, i want to do it eventually for all nodes, but there you have it. my questions are:
1. is this something that the dom4j developers would be interested in having in the main source tree? 2. if so, can someone suggest the least intrusive way to introduce this into the code? my naive idea was to add get/set position methods to the Node and Element apis (elements have more position data than other nodes of course), add instance variables to actually store that data in AbstractNode and AbstractElement, and if SAXContentHandler gets a Locator, set the position data. one could argue, however, that that would be a waste of memory for dom4j users that don't care about position information... thanks. - donald -----Forwarded Message----- From: Donald Ball <[EMAIL PROTECTED]> To: dom4j <[EMAIL PROTECTED]> Subject: Re: [dom4j-user] given a Node, can i get its original position information? Date: 04 Jun 2002 18:46:30 -0400 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-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev