IntelliJ Java IDE
The moose likes XML and Related Technologies and the fly likes Is there a way to determine XPATH from an XML file and offset position? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Is there a way to determine XPATH from an XML file and offset position?" Watch "Is there a way to determine XPATH from an XML file and offset position?" New topic
Author

Is there a way to determine XPATH from an XML file and offset position?

Kelly Dolan
Ranch Hand

Joined: Jan 08, 2002
Posts: 98
I'm in a strange situation. I have an XML document. I hand the XML document as a string to a "black box" that evaluates the content and returns a list of findings. I next display the XML document (using XSL) along w/ the findings. On click of a finding, I need to scroll to the corresponding location in the document.

The core business logic for the display currently supports scroll to given an XPATH and offset (the offset I believe being the number of characters w/in the element identified by the XPATH). Each finding corresponds with some location w/in the XML content (PCDATA) but the locations are represented as the character offset from the beginning of the XML as a string. The locations take into consideration the XML declaration, comments, PIs, etc.

One approach is to convert a fixed location w/in an XML string to an XPATH and offset w/in an element. Does anyone know if there is a library or function that exists that does this? This is not something I care to implement. I have a Plan B if not.

Thanks!
Kelly
 
 
subject: Is there a way to determine XPATH from an XML file and offset position?
 
Threads others viewed
decode an inputstream
Extract a unique identifier for any given Element
XPATH to REGEX?
general xml question
XPath and Modified DOM document object...
IntelliJ Java IDE