How to implement XSLT tokenize function?

Sparky

New Member
It seems like EXSLT tokenize function is not available with PHP XSLTProcessor (XSLT 1.0).I tried to implement it in pure XSL but I can't make it work :\[code\]<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/"> <func:function name="my:tokenize"> <xsl:param name="string"/> <xsl:param name="separator" select="'|'"/> <xsl:variable name="item" select="substring-before(concat($string,$separator),$separator)"/> <xsl:variable name="remainder" select="substring-after($string,$separator)"/> <xsl:variable name="tokens"> <token><xsl:value-of select="$item"/></token> <xsl:if test="$remainder!=''"> <xsl:copy-of select="my:tokenize($remainder,$separator)"/> </xsl:if> </xsl:variable> <func:result select="exsl:node-set($tokens)"/> </func:function> <xsl:template match="/"> <xsl:copy-of select="my:tokenize('a|b|c')"/> </xsl:template></xsl:stylesheet>\[/code\]Expected result :\[code\] <token>a</token><token>b</token><token>c</token>\[/code\]Actual result :\[code\] abc\[/code\]I know this question has been posted many times but I can't find a simple solution.Thank you for your help.
 
Back
Top