I am trying to print variable value in second for loop of xslt but not getting displayed
here is my code
<xsl:for-each select="CampaignData/Mailer/CustomerInfo/CustInfFld/Coupons/Cust_Sel_Coupons">
<xsl:sort select="@CouponPosition"/>
<xsl:variable name="CouponID">
<xsl:value-of select="@CouponID"/>
</xsl:variable>
<xsl:for-each select="CampaignData/Mailer/Coupons/Cntr_Sel_Coupons">
<div style='color:red;'><xsl:value-of select='$CouponID'/></div>
</xsl:for-each>
</xsl:for-each>
The
selectattribute of the nestedxsl:for-eachdoesn’t select anything and this is why its body isn’t executed even once.Inside the inner
xsl:for-eachyour current node is of the form:The select attribute of the inner
xsl:for-eachspecifies:this is a relative XPath expression and it is resolved off the current node. Thus, the specified
selectfor the innerxsl:for-eachis actually (from outside of the outerxsl:for-each):It is highly unlikely there are any such nodes in the source XML document that you haven’t shown.
Without having the source XML it isn’t possible to say what exactly the relative expression should be — most likely:
Change:
to: