I've been reading the XPath specs and using the XPath Visualizer Tool in order to obtain deeper knowledge of XPath 1.0.
I can select the root node of a document by using /
. When I enter this character into the tool, no visual selection is indicated in it's text editor, but the status bar contains the following text:
"/: 1 node selected"
,
which is what was expected. What's selected is the invisible root node (document root).
However when I entered the /*/parent::*
character sequence into the tool, I got
"/*/parent::*: Zero nodes selected"
.
Is the tool correct or should this expression also select the root node?
I also tried with the ancestor axis instead of parent for which the specs say the following:
the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node
which specifically mentions the root node. Since in my case the context node from the first location step is the document element, shouldn't the result set contain the root node? Why not?
The specs also say this:
the parent axis contains the parent of the context node, if there is one
and this:
/ selects the document root (which is always the parent of the document element)
Note that I was intentionally using the same terms in the above text as are being used within the spec.
Edit01
The xml document loaded into the tool is a well formed XML document and therefore non-empty.