I have an xml like this:
<xml>
<node name="1">node1</node>
<node name="2">node2</node>
<node name="3">node3</node>
<node>node4</node>
</xml>
How do I check that <node name="3">node3</node> is the last node with a @name attribute?
You could make use of the following-sibling operator here. Assuming you were positioned on a node elemenet, you just need to check the current node has an name attribute but no following-sibling does
This could also be done as part of a template match
For example, try the following XSLT
When applied to your XML, the following is output
EDIT: Actually, in a template match, you could make use of last here. The following template match should also work.