I am not a XSL expert and struggling with the simple logic:
I have a XSL variable with the value of "A,B,C", want to split it and store the individual values into three different XSL variable like
X= A
Y= B
Z= C
but sometimes either it may have only one/two value or no values...
if it has only one value then the variable values should be like
X= A
Y=
Z=
if it does not have any value then
X=
Y=
Z=
Kindly help me with the XSL code for the same
Lets say:
Tags has the value of "Test,Demo,Sample" then i would like to split like this
<xsl:choose>
<xsl:when test="contains($Tags,',')">
<xsl:variable name="Tags1">
<xsl:value-of select="substring-before($Tags,',')" />
</xsl:variable>
<xsl:variable name="ATag1">
<xsl:value-of select="substring-after($Tags,',')" />
</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="Tags1"/>
<xsl:variable name="ATags1"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains($ATags1,',')">
<xsl:variable name="Tags2">
<xsl:value-of select="substring-before($ATags1,',')" />
</xsl:variable>
<xsl:variable name="ATag2">
<xsl:value-of select="substring-after($ATags1,',')" />
</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="Tags2"/>
<xsl:variable name="ATags2"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains($ATags2,',')">
<xsl:variable name="Tags3">
<xsl:value-of select="substring-before($ATags2,',')" />
</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="Tags3"/>
</xsl:otherwise>
</xsl:choose>
however it is not working for me...