I don't understand why this test
count(.|../@*)=count(../@*)
( from Dave Pawson's Home page )
identify an attribute node :(
could someone give me a detailled explanation ?
A few things to understand:
.
refers to the current node (aka "context node")|
) never duplicates nodes, i.e. (.|.)
results in one node, not twoself::
axis you could use in theory (e.g. self::*
works to find out if a node is an element), but self::@*
does not work, so we must use something differentKnowing that, you can say:
../@*
fetches all attributes of the current node's parent (all "sibling attributes", if you will)(.|../@*)
unions the current node with them – if the current node is an attribute, the overall count does not change (as per #3 above)count(.|../@*)
equals count(../@*)
, the current node must be an attribute node.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With