A few things to understand:
. refers to the current node (aka "context node")- the node attribute has a parent element (to which it belongs)
- the XPath join operation (with
| ) never duplicates nodes, i.e. (.|.) leads to one node, not two - there is an axis
self:: , which you could use theoretically (for example, self::* works to find out if the element is a node), but self::@* does not work, so we should use something else
Knowing this, you can say:
../@* retrieves all attributes of the current parent node (all attributes are "sibling") if you do)(.|../@*) combines the current node with them - if the current node is an attribute, the total counter does not change (according to No. 3 above)- therefore, if
count(.|../@*) is equal to count(../@*) , the current node must be a node attribute .
source share