Thanks in advance for your support. I was just stuck with a problem and tried a lot in all ways.
I have an XSLT 1.0 that need to parse the value of an xml tag by comma and store it in array.
<OPTIONS>val1,,val2,val3,,,val4</OPTIONS>
Here I need to parse the OPTIONS field value by comma and then store it in array. Here I was stuck with the way of storing it in array for further use.
Please advice
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:variable name="inline-array">
<!--<Item>A</Item>
<Item>B</Item>
<Item>C</Item>-->
<xsl:call-template name="splitByComma">
<xsl:with-param name="str" select="OPTIONS"/>
</xsl:call-template>
</xsl:variable>
<xsl:template match="/">
<xsl:param name="array" select="document('')/*/xsl:variable[@name='inline-array']/*"/>
<xsl:value-of select="$array[1]"/>
</xsl:template>
<xsl:template name="splitByComma">
<xsl:param name="str"/>
<xsl:choose>
<xsl:when test="contains($str,',')">
<item><xsl:value-of select="substring-before($str,',')"/></item>
<xsl:call-template name="splitByComma">
<xsl:with-param name="str"
select="substring-after($str,',')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<item><xsl:value-of select="$str"/></item>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
