A single-node XPath is an XPath expression using a subset of XPath constructs and having a normalised form. A single-node XPath will always resolve to zero or one node when evaluated against any document.
A single-node XPath is composed of a sequence of single-node XPath parts. A single-node XPath part is made up of the following sequence of tokens:
A single-node XPath can be converted into an expanded form by replacing all the prefixes of all the node names in the original path with the following sequence:
An expanded form of a single-node XPath is not a valid XPath expression. Two single-node XPaths evaluated on the same document will return the same result if and only if they convert to the same expanded form. Therefore, two single-node XPaths can be compared for equivalence without evaluating against any document.
Given a node in a document, we can determine a single-node XPath expression for that node. We first define parent (node) and indexOfChild (parentNode, childNode) as follows:
We define singleNodeXPath (node), which gives a single-node XPath for node, as follows.
-- SimonMiles - 13 Mar 2006
to top