PHP XSLTProcessor (XSLT 1.0) では EXSLT トークン化機能が利用できないようです。
純粋な XSL で実装しようとしましたが、動作させることができません:
<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>
期待される結果 :
<token>a</token><token>b</token><token>c</token>
実結果 :
abc
この質問が何度も投稿されていることは知っていますが、簡単な解決策が見つかりません。
ご協力ありがとうございました。