繁体   English   中英

为什么替换功能在xslt 2.0中不起作用

[英]Why is the Replace function is not working in xslt 2.0

替换功能在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;amp;', '&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 ==>给定错误

该工具使用XSLT 1.0(javax.xml.transform)

http://www.xsltcake.com/ ==>出现错误

该工具使用XSLT 1.0(浏览器版本,即Firefox中的Transformiix)

http://xslt.online-toolz.com/tools/xslt-transformation.php ==>给定错误

该工具使用XSLT 1.0(libxsl)

http://xslttest.appspot.com/ ==>未收到error.its正常。

该工具使用XSLT 2.0(Saxonica的SAXON 9.3.0.5)

http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog ==>给定错误

该工具使用XSLT 1.0(浏览器版本,即Firefox中的Transformiix)

正如其他人已经提到的那样,函数fn:replace是XSLT 2.0(实际上是XPath 2.0的一部分,它是XSLT 2.0的一部分)中添加的函数。 使用2.0处理器(例如SaxonExseltAltova )运行样式表,您应该会满意 如何为您的产品配置它取决于它是否支持使用/插入其他处理器。

注意:用于fn的名称空间是错误的。 您无需指定该名称空间(它是隐式的),但是如果您指定了该名称空间,请使用xmlns:fn="http://www.w3.org/2005/xpath-functions"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM