title: XSLT 1.0 String split template not working
body: <p>I am new to XSLT and am having an issue with templates. I have an input xml file as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Node&gt;
  &lt;PHASE1_TYPE&gt;LEFT,TOP&lt;/PHASE1_TYPE&gt;
  &lt;PHASE1_HOL&gt;TOK,ZUR,VIN&lt;/PHASE1_HOL&gt;
  &lt;PHASE2_TYPE&gt;RIGHT,BOTTOM&lt;/PHASE2_TYPE&gt;
  &lt;PHASE2_HOL&gt;CHF&lt;/PHASE2_HOL&gt;
  &lt;/Node&gt;
  </code></pre>
  
  <p>My xslt is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
  
  &lt;xsl:template  name="tokenize"&gt;
      &lt;xsl:param name="text" select="."/&gt;
      &lt;xsl:param name="separator" select="','"/&gt;
      &lt;xsl:choose&gt;
          &lt;xsl:when test="not(contains($text, $separator))"&gt;
              &lt;Holiday&gt;
                  &lt;xsl:value-of select="normalize-space($text)"/&gt;
              &lt;/Holiday&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
              &lt;Holiday&gt;
                  &lt;xsl:value-of select="normalize-space(
                      substring-before($text, $separator))"/&gt;
              &lt;/Holiday&gt;
              &lt;xsl:call-template name="tokenize"&gt;
                  &lt;xsl:with-param name="text" 
                    select="substring-after($text, $separator)"/&gt;
              &lt;/xsl:call-template&gt;
          &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  
  
  &lt;xsl:output method="xml" encoding="UTF-8" indent="yes"/&gt;
  &lt;xsl:template match="/"&gt;
  &lt;Document&gt;
   &lt;xsl:attribute name="xsi:noNamespaceSchemaLocation" 
    namespace="http://www.w3.org/2001/XMLSchema-instance"
      &gt;C:/usr/NONMAR~1/Output.xsd&lt;/xsl:attribute&gt;
  &lt;xsl:for-each select="Node"&gt;
  &lt;Deal&gt;
  
  &lt;DealType&gt;
  &lt;xsl:value-of select="string(PHASE1_TYPE)"/&gt;
  &lt;/DealType&gt;
  &lt;Holidays&gt;
  
  &lt;xsl:call-template name="tokenize"&gt;
  &lt;xsl:with-param name="text" select="string(PHASE1_HOL)"/&gt;
  &lt;xsl:with-param name="separator" select="','"/&gt;
  &lt;/xsl:call-template&gt;
  &lt;/Holidays&gt;
  &lt;/Deal&gt;
  &lt;Deal&gt;
  
  &lt;DealType&gt;
  &lt;xsl:value-of select="string(PHASE2_TYPE)"/&gt;
  &lt;/DealType&gt;
  
  &lt;Holidays&gt;
  &lt;xsl:call-template name="tokenize"&gt;
  &lt;xsl:with-param name="text" select="string(PHASE2_HOL)"/&gt;
  &lt;xsl:with-param name="separator" select="','"/&gt;
  &lt;/xsl:call-template&gt;
  &lt;/Holidays&gt;
  &lt;/Deal&gt;
  &lt;/xsl:for-each&gt;
  &lt;/Document&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>After transformation, my output is: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="C:/usr/NONMAR~1/Output.xsd"&gt;
  
  &lt;Deal&gt;
  &lt;DealType&gt;LEFT,TOP&lt;/DealType&gt;
  &lt;Holidays&gt;
  &lt;Holiday/&gt;
  &lt;/Holidays&gt;
  &lt;/Deal&gt;
  
  &lt;Deal&gt;
  &lt;DealType&gt;RIGHT,BOTTOM&lt;/DealType&gt;
  &lt;Holidays&gt;
  &lt;Holiday/&gt;
  &lt;/Holidays&gt;
  &lt;/Deal&gt;
  
  &lt;/Document&gt;
  </code></pre>
  
  <p>but the expected Output is : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="C:/usr/NONMAR~1/Output.xsd"&gt;
  
  &lt;Deal&gt;
  &lt;DealType&gt;LEFT,TOP&lt;/DealType&gt;
  &lt;Holidays&gt;
  &lt;Holiday&gt;TOK&lt;/Holiday&gt;
  &lt;Holiday&gt;ZUR&lt;/Holiday&gt;
  &lt;Holiday&gt;VIN&lt;/Holiday&gt;
  &lt;/Holidays&gt;
  &lt;/Deal&gt;
  
  &lt;Deal&gt;
  &lt;DealType&gt;RIGHT,BOTTOM&lt;/DealType&gt;
  &lt;Holidays&gt;
  &lt;Holiday&gt;CHF&lt;/Holiday&gt;
  &lt;/Holidays&gt;
  &lt;/Deal&gt;
  
  &lt;/Document&gt;
  </code></pre>
  
  <p>I am using xslt 1.0 and do not want to use third party functions like EXSLT. Again, I am new to XSLT and do not have time right now to learn it. Would really appreciate if someone can tell me why this template is not working properly. Thanks!!</p>