替换功能在 xslt 2.0 中不起作用
xslt 看起来像这样:
<xsl:stylesheet version='2.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:fn='http://www.w3.org/2005/xpath-funcations'>
<xsl:output
method="xml"
encoding="utf-8"
media-type="application/xml"
/>
<xsl:template match='/'>
<items>
<xsl:apply-templates select="response/result/doc"/>
</items>
</xsl:template>
<!-- search results xslt -->
<xsl:template match="doc">
<xsl:variable name="ShortDescription" select="str[@name = 'ShortDescription']"/>
<shortdescription><xsl:value-of select="replace($ShortDescription, '&amp;', '&')" disable-output-escaping="yes"/></shortdescription>
</xsl:template>
</xsl:stylesheet>
当我们使用替换函数时,我们收到此错误:
我正在检查在线 xslt 测试仪上的替换功能,有些工具给出了错误,有些则不是,为什么会这样?
www.utilities-online.info/xsltransformation/#.U-inrWNknIU ==> given error
http://www.xsltcake.com/ ==> given error
http://xslt.online-toolz.com/tools/xslt-transformation.php ==> given error
http://xslttest.appspot.com/ ==> not given error.its working fine.
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog ==> given error
我正在使用 solr 4.0,xslt 2.0 和 xml 1.0
请告诉我如何在 xslt 2.0 中处理此替换功能
提前致谢
最佳答案
www.utilities-online.info/xsltransformation/#.U-inrWNknIU ==> given error
该工具使用 XSLT 1.0 (javax.xml.transform)
http://www.xsltcake.com/ ==> given error
该工具使用 XSLT 1.0(浏览器版本,即 Firefox 中的 Transformiix)
http://xslt.online-toolz.com/tools/xslt-transformation.php ==> given error
该工具使用 XSLT 1.0 (libxsl)
http://xslttest.appspot.com/ ==> not given error.its working fine.
该工具使用 XSLT 2.0(来自 Saxonica 的 SAXON 9.3.0.5)
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog ==> given error
该工具使用 XSLT 1.0(浏览器版本,即 Firefox 中的 Transformiix)
正如其他人已经评论的那样,函数 fn:replace
是 XSLT 2.0(实际上是 XPath 2.0,它是 XSLT 2.0 的一部分)中添加的功能。使用 2.0 处理器运行样式表(如 Saxon 、 Exselt 或 Altova ),应该没问题。如何为您的产品配置它取决于它是否支持使用/插入不同的处理器。
注意:您使用的命名空间 fn
是错的。您不需要指定该命名空间(它是隐式的),但如果您这样做,请使用 xmlns:fn="http://www.w3.org/2005/xpath-functions"
.
关于xml - 为什么替换功能在 xslt 2.0 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25240756/