我有一个非常庞大的xsl文件,但在使用“tokenize”解析逗号分隔字符串的部分时出现错误。为简单起见,我将其简化为仅测试解析器的部分,但似乎无法取得任何进展。我一直收到以下错误:
需要表达式。tokenize(-->[<--text],',')
我尝试使用其他帖子中共享的一些示例xsl,但从未成功使其工作。我很难理解为什么我的xsl代码无效。它似乎非常简单,但我认为我错过了一些简单的东西。希望能提供任何帮助使我朝正确的方向前进,不胜感激。
XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:for-each select="tokenize([text],',')"/>
<items>
<item>
<xsl:value-of select="."/>
</item>
</items>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<root>
<text>Item1, Item2, Item3</text>
</root>
我期望的XML输出如下:
<items>
<item>Item1</item>
<item>Item2</item>
<item>Item3</item>
</items>
谢谢!