TonyMarston
Programmer
I wish to process my XML data in a particular oder, so I am using the following code:
Within the template I wish to obtain a value from the previous node so I can emulate "on change of value do so-and-so", so I use the following code:
The problem is that $position-1 will only give me the previous node in the original unsorted sequence, not the sorted sequence.
In a 'conventional' programming language I could save the current value in a variable so that I could test it the next time around, but even this simple act does not appear to be possible in XSLT.
Does anyone have any ideas?
Code:
<xsl:apply-templates select="SYSTEM/TABLE/OCC">
<xsl:sort select="FIELD3"/>
<xsl:sort select="FIELD4"/>
</xsl:apply-templates>
Code:
<xsl:template match="SYSTEM/TABLE/OCC">
<xsl:variable name="position" select="position()" />
<xsl:variable name="prev">
<xsl:if test="$position > 1">
<xsl:value-of select="/SYSTEM/TABLE/OCC[$position -1]/FIELD3" />
</xsl:if>
</xsl:variable>
....
</xsl:template>
In a 'conventional' programming language I could save the current value in a variable so that I could test it the next time around, but even this simple act does not appear to be possible in XSLT.
Does anyone have any ideas?