Hello.
I have the following XML code.
Code:
<doc>
<EOB>
<DETAIL>
<DETAILLINE>
<CRCDATA>
<CRCDATALINE>
<CRC>LINE1CRC1</CRC>
<CRCFUNCTION>700</CRCFUNCTION>
</CRCDATALINE>
<CRCDATALINE>
<CRC>LINE1CRC2</CRC>
<CRCFUNCTION>900</CRCFUNCTION>
</CRCDATALINE>
</CRCDATA>
</DETAILLINE>
<DETAILLINE>
<CRCDATA>
<CRCDATALINE>
<CRC>LINE2CRC3</CRC>
<CRCFUNCTION>700</CRCFUNCTION>
</CRCDATALINE>
<CRCDATALINE>
<CRC>LINE2CRC4</CRC>
<CRCFUNCTION>700</CRCFUNCTION>
</CRCDATALINE>
</CRCDATA>
</DETAILLINE>
</DETAIL>
</EOB>
</doc/
I have the following "for-each" loop where I need to check the <CRC> and
<CRCFUNCTION> for each SEPARATE <DETAILLINE> as it goes through the loop. I have a variable that I need to set to "Y" if <CRC> has a value and it's
corresponding <CRCFUNCTION> has a value of 900 in any of the associated <CRCDATALINE> for a specific <DETAILLINE>.
Using the code below, my variable is always being set to "Y" for both the first <DETAILLINE> and the second <DETAILLINE>.
The variable should be "Y" for the first DETAILLINE and "N" for the second
<DETAILLINE>.
Code:
<xsl:for-each select="DETAILLINE">
<xsl:variable name="varDenialCRC">
<xsl:choose>
<xsl:when test="CRCDATA/CRCDATALINE/CRCFUNCTION[.='900']
and ../../CRCDATA/CRCDATALINE/CRC[.!='']">
Y
</xsl:when>
<xsl:otherwise>
N
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
</xsl:for-each>
Any help with this will be greatly appreciated!
Thanks,
Rita