title: How to implement XSLT tokenize function?
body: <p>It seems like EXSLT tokenize function is not available with PHP XSLTProcessor (XSLT 1.0).</p>
  
  <p>I tried to implement it in pure XSL but I can't make it work :</p>
  
  <pre><code>&lt;xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:func="http://exslt.org/functions"
      xmlns:exsl="http://exslt.org/common"
      xmlns:my="http://mydomain.com/"&gt;
  
      &lt;func:function name="my:tokenize"&gt;
          &lt;xsl:param name="string"/&gt;
          &lt;xsl:param name="separator" select="'|'"/&gt;
          &lt;xsl:variable name="item" select="substring-before(concat($string,$separator),$separator)"/&gt;
          &lt;xsl:variable name="remainder" select="substring-after($string,$separator)"/&gt;
          &lt;xsl:variable name="tokens"&gt;
              &lt;token&gt;&lt;xsl:value-of select="$item"/&gt;&lt;/token&gt;
              &lt;xsl:if test="$remainder!=''"&gt;
                  &lt;xsl:copy-of select="my:tokenize($remainder,$separator)"/&gt;
              &lt;/xsl:if&gt;
          &lt;/xsl:variable&gt;
          &lt;func:result select="exsl:node-set($tokens)"/&gt;
      &lt;/func:function&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;xsl:copy-of select="my:tokenize('a|b|c')"/&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Expected result :</p>
  
  <pre><code>    &lt;token&gt;a&lt;/token&gt;&lt;token&gt;b&lt;/token&gt;&lt;token&gt;c&lt;/token&gt;
  </code></pre>
  
  <p>Actual result :</p>
  
  <pre><code>    abc
  </code></pre>
  
  <p>I know this question has been posted many times but I can't find a simple solution.</p>
  
  <p>Thank you for your help.</p>