Last active
January 27, 2022 15:34
-
-
Save afreeland/5532635 to your computer and use it in GitHub Desktop.
XSLT: Set XSLT variable via choose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:variable name="Qty"> | |
<xsl:choose> | |
<xsl:when test="Item_Item/Item_Locations/Item_Location[LocationID = $LocationID and ChannelID = $ChannelID]/Quantity = ''"> | |
<xsl:text>0</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="substring-before(Item_Item/Item_Locations/Item_Location[LocationID = $LocationID and ChannelID = $ChannelID]/Quantity,'.')"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have always felt that variables are quite limited in XSLT. Once you set them, you cannot change them and
I was always trying to create a choose statement and set my variable to different values in the choose but you can’t do that because then the scope of the variable is only in that choose.
The way to do it is to not use the select attribute for setting the attribute but rather put the choose INSIDE the variable like Charles does here…