帮帮我伙计们。我只是试图声明一个简单的结果树片段并对其进行迭代。
..。
<xsl:variable name="rtf">
<item-list>
<item id="1">one</item>
<item id="2">two</item>
<item id="3">three</item>
<item id="4">four</item>
</item-list>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($rtf)/item-list/item">
<xsl:value-of select="@id"/>
</xsl:for-each>..。
我是不是完全搞错了这是怎么回事?
编辑:-我使用的是.NET XslCompiledTransform,并具有正确的msxsl命名空间声明-xmlns:msxsl=“urn:schemas-microsoft:xslt”
转换执行得很好--问题是没有输出。
发布于 2009-12-07 21:07:13
我怀疑您在样式表中声明了默认名称空间。这将有效地将和元素放到命名空间中。若要使用XPath 1.0选择命名空间限定元素,必须始终在表达式中使用前缀。
因此,如果样式表顶部有这样的内容:
<xsl:stylesheet xmlns="http://example.com"...>然后,还需要添加以下内容:
<xsl:stylesheet xmlns="http://example.com" xmlns:x="http://example.com"...>然后在XPath表达式中使用"x“前缀:
<xsl:for-each select="msxsl:node-set($rtf)/x:item-list/x:item">
<xsl:value-of select="@id"/>
</xsl:for-each>如果这招管用的话请告诉我。我只是在推测。
发布于 2009-12-07 21:20:35
与MSXSL不同的是,XslCompiledTransform在EXSLT公共命名空间中提供了node-set()函数,其中包含应该是:
<xsl:stylesheet xmlns:exslt="http://exslt.org/common">
...
<xsl:for-each select="exslt:node-set($rtf)/item-list/item">
...
</xsl:stylesheet>发布于 2009-12-07 13:12:36
这在我看来没问题。
但是,您是否正确地声明了扩展函数的msxsl命名空间?就像这样:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">我假设您在这里使用Microsoft XSLT处理器。
https://stackoverflow.com/questions/1859839
复制相似问题