I have an XSL template that is selected for execution (below). What I would like to do is be able to tell if I am the last Unit being matched.
<xsl:template match="Unit[@DeviceType = 'Node']">
<!-- Am I the last Unit in this section of xml? -->
<div class="unitchild">
Node: #<xsl:value-of select="@id"/>
</div>
</xsl:template>
Example XML
<Unit DeviceType="QueueMonitor" Master="1" Status="alive" id="7">
<arbitarytags />
<Unit DeviceType="Node" Master="0" Status="alive" id="8"/>
<Unit DeviceType="Node" Master="0" Status="alive" id="88"/>
</Unit>
If you want to test whether it is the last Unit element at the same level (with the same parent element), even if there are arbitrary tags before, after, and in-between then this would work:
However, if you are applying templates for a subset, the last in the document may not be in the set being processed. For that, you can test if the
position() = last()