Quoting http://www.exslt.org/str/functions/tokenize/index.html http://www.exslt.org/str/functions/tokenize/index.html
以下 XSLT 处理器支持 str:tokenize:
- 4XSLT,来自 4Suite。 (版本0.12.0a3)
- 来自 Daniel Veillard 等人的 libxslt。 (版本1.0.19)
由于 PHP 使用 libxslt,这意味着tokenize
可用,但您必须使用正确的扩展名称空间(您不这样做):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
extension-element-prefixes="str"
…
然后您可以使用 tokenize 作为函数,例如构建一个包含数字 1-12 的选择框:
<select name="months">
<xsl:for-each select="str:tokenize('1,2,3,4,5,6,7,8,9,10,11,12', ',')">
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</select>