I'm facing a stupid issue trying to output XML tags when processing a file.
My input xml is as simple as follows:
<?xml version="1.0" encoding="UTF-8"?>
<body>
<information>
<role_code>0003,3,0016</role_code>
</information>
</body>
My XSL is built to add an 'A' when the '3' token is found in the role_code tag
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" omit-xml-declaration="yes" />
<xsl:template match="role_code" name="tokenize">
<xsl:param name="text" select="."/>
<xsl:param name="separator" select="','"/>
<xsl:choose>
<xsl:when test="not(contains($text, $separator))">
<xsl:if test="$text = '3'">
A<xsl:value-of select="$text"/>
</xsl:if>
<xsl:if test="not($text = '3')">
<xsl:value-of select="$text"/>
</xsl:if>
<xsl:text disable-output-escaping ="yes"><![CDATA[</role_code>]]></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:if test="substring-before($text, $separator) = '3'">
A<xsl:value-of select="substring-before($text, $separator)"/>,
</xsl:if>
<xsl:if test="not(substring-before($text, $separator) = '3')">
<xsl:value-of select="substring-before($text, $separator)"/>,
</xsl:if>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
My hopefully stupid issue is that I cannot output the initial tag without having errors on non matching tags
The current XSL outputs the following:
0003, A3, 0016</role_code>
and I'm not facing where to include the opening "role_code" tag