The following stylesheet processes each <status> node present within an XDS document, and tags each node with the position of that node. For example, if the XDS document contains 3 <status> nodes, the first node will be rewritten as <status position=”0″> etc. The code listed below makes use of the XSLT function preceding-sibling in order to figure out at what position the node is placed within the context of the XDS document. The code loops around each node, one after the other, and tags each node with the relative position.

<xsl:stylesheet exclude-result-prefixes="query cmd dncv" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="srcQueryProcessor"/>
<xsl:param name="destQueryProcessor"/>
<xsl:param name="srcCommandProcessor"/>
<xsl:param name="destCommandProcessor"/>
<xsl:param name="dnConverter"/>
<xsl:param name="fromNds"/>

<xsl:template match="output/status">
    <xsl:variable name="varPositionValue" select="count(preceding-sibling::*/operation-data/*)"/>
    <xsl:message>[Status] Adding in position value of '<xsl:value-of select="$varPositionValue"/>'</xsl:message>
    <xsl:copy>
        <xsl:attribute name="position">
            <xsl:value-of select="$varPositionValue"/>
        </xsl:attribute>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>

You can use the code below to ensure that multiple email notifications are not sent out when processing an XDS document with multiple <status> tags.

<conditions>
    <and>
        <if-operation op="equal">status</if-operation>
        <if-xpath op="true">@level='success'</if-xpath>
        <if-xpath op="true">@position='0'</if-xpath>
        <if-global-variable name="gcvAudit" op="equal">true</if-global-variable>
        <if-local-variable mode="regex" name="varUserEmailAddress" op="equal">^.+$</if-local-variable>
    </and>
</conditions>