comparing nodes
[nobr]How do you compare values of node that are not child?I want to loop through all the currentActivity while looping through CurrentActivity2. So you read the first currentActivity then loop through all the CurrentActivity2 nodes seeing if the TransDetailCount of currentActivity match any of the CurrentActivity2 TransDetailCount.
*** This is just a sample of the XML, I just need to know how to get all of the currentActivity2 nodes that map to the CurrentActivity based off the TransDetailCount
<OUTPUT>
<STATEMENT>
<CurrentActivity>
<TransDesc>First current </TransDesc>
<TransDetailCount>1</TransDetailCount>
</CurrentActivity>
<CurrentActivity>
<TransDesc>second current </TransDesc>
<TransDetailCount>2</TransDetailCount>
</CurrentActivity>
<CurrentActivity>
<TransDesc>Third current </TransDesc>
<TransDetailCount>3</TransDetailCount>
</CurrentActivity>
<CurrentActivity2>
<TransDesc> AC 1.1 </TransDesc>
<TransDetailCount>1</TransDetailCount>
</CurrentActivity2>
<CurrentActivity2>
<TransDesc>AC 1.2 </TransDesc>
<TransDetailCount>1</TransDetailCount>
</CurrentActivity2>
<CurrentActivity2>
<TransDesc>AC 2.1 </TransDesc>
<TransDetailCount>2</TransDetailCount>
</CurrentActivity2>
</STATEMENT>
</OUTPUT>
I抳e tried a few things and nothing works:
1.) This does not print any of the currentActivity2 nodes
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<xsl:variable name="outputData" select="/OUTPUT"/>
<xsl:variable name="statementData" select="$outputData/STATEMENT"/>
<xsl:for-each select="$statementData/CurrentActivity">
<tr>
<td><xsl:value-of select="TransDesc"/></td>
<td><xsl:value-of select="TransDetailCount"/></td><br/>
</tr>
<xsl:for-each select="$statementData/CurrentActivity2[TransDetailCount='$statementData/CurrentActivity/TransDetailCount']">
In
<td><xsl:value-of select="TransDesc"/></td><br/>
<td><xsl:value-of select="TransDetailCount"/></td><br/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
2.) This just prints all of the currentActivity2 under each currentActivity
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<xsl:variable name="outputData" select="/OUTPUT"/>
<xsl:variable name="statementData" select="$outputData/STATEMENT"/>
<xsl:for-each select="$statementData/CurrentActivity">
<tr>
<td><xsl:value-of select="TransDesc"/></td>
<td><xsl:value-of select="TransDetailCount"/></td><br/>
</tr>
<xsl:for-each select="$statementData/CurrentActivity2">
<xsl:if test="TransDetailCount = $statementData/CurrentActivity/TransDetailCount">
In
<td><xsl:value-of select="TransDesc"/></td><br/>
<td><xsl:value-of select="TransDetailCount"/></td><br/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I could not get the compare or codepoint-equal xsl functions to work in the xsl:if. Any help would be a great help.[/nobr]

