<?xml version="1.0"?>

<!-- Loop Example: Transforming comma-separated values (csv)
     GPL (c) Oliver Becker, 2000-07-01
     obecker@informatik.hu-berlin.de
-->

<xslt:transform version="1.0"
                xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
                xmlns:loop="http://informatik.hu-berlin.de/loop"
                exclude-result-prefixes="loop">

<xslt:output method="xml" indent="yes" />

<xslt:template match="text()">
   <xslt:variable name="content" select="." />
   <xslt:if test="$content">
      <tokens>
         <loop:while test="contains($content,',')">
            <loop:do>
               <value>
                  <xslt:value-of 
                        select="normalize-space(substring-before(
                                                    $content,','))" />
               </value>
            </loop:do>
            <loop:last>
               <value>
                  <xslt:value-of select="normalize-space($content)" />
               </value>
            </loop:last>
            <loop:update name="content"
                         select="substring-after($content,',')" />
         </loop:while>
      </tokens>
   </xslt:if>
</xslt:template>

</xslt:transform>
