title: Comma separated string parsing XSLT to for-each node
body: <p>I have an input string which has csv values. Eg., 1,2,3
  I would need to separate each values and assign to target node in for-each loop.</p>
  
  <p>I got this below template that splits the input string based on delimiter. How can I assign each of the delimited values to the target element in for-each loop.</p>
  
  <pre><code>&lt;xsl:template name="output-tokens"&gt;
  &lt;xsl:param name="list"/&gt;
  &lt;xsl:param name="delimiter"/&gt;
  &lt;xsl:variable name="newlist"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="contains($list, $delimiter)"&gt;
        &lt;xsl:value-of select="normalize-space($list)"/&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:value-of select="concat(normalize-space($list), $delimiter)"/&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:variable&gt;
  &lt;xsl:variable name="first" select="substring-before($newlist, $delimiter)"/&gt;
  &lt;xsl:variable name="remaining"
                select="substring-after($newlist, $delimiter)"/&gt;
  &lt;xsl:variable name="count" select="position()"/&gt;
  &lt;num&gt;
    &lt;xsl:value-of select="$first"/&gt;
  &lt;/num&gt;
  &lt;xsl:if test="$remaining"&gt;
    &lt;xsl:call-template name="output-tokens"&gt;
      &lt;xsl:with-param name="list" select="$remaining"/&gt;
      &lt;xsl:with-param name="delimiter"&gt;
        &lt;xsl:value-of select="$delimiter"/&gt;
      &lt;/xsl:with-param&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Input xml:</p>
  
  <pre><code>&lt;out1:AvailableDates&gt;
  &lt;out1:AvailableDate&gt;15/12/2011,16/12/2011,19/12/2011,20/12/2011,21/12/2011&lt;/out1:AvailableDate&gt;
  &lt;/out1:AvailableDates&gt;
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>&lt;tns:AvailableDates&gt;
  &lt;tns:AvailableDate&gt;15/12/2011&lt;/tns:AvailableDate&gt;
  &lt;tns:AvailableDate&gt;16/12/2011&lt;/tns:AvailableDate&gt;
  &lt;tns:AvailableDate&gt;120/12/2011&lt;/tns:AvailableDate&gt;
  &lt;/tns:AvailableDates&gt;
  </code></pre>