为什么 fn:matches 和 fn:replace 在 XSLT 2.0 中抛出解析错误?

Why are fn:matches and fn:replace throwing parse errors in XSLT 2.0?

我试图在我的 XSLT 样式表中使用这两个字符串函数(matchesreplace)。但是在运行时我得到以下错误 matches 和类似的错误 replace:

Caused by: org.xml.sax.SAXException: Parse Error in matches function.
oracle.xdo11g.xpath.XPathException: Parse Error in matches function.
    at oracle.xdo11g.xslt.XSLProcessor.reportException(XSLProcessor.java:965)
    at oracle.xdo11g.xslt.XSLProcessor.newXSLStylesheet(XSLProcessor.java:725)
    at oracle.xdo11g.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:391)

xslt处理器版本为2.0,按照http://www.w3schools.com/xsl/func_systemproperty.asp应该支持这些功能。

我也尝试复制 w3org (http://www.w3.org/TR/xpath-functions/#func-matches) 上列出的简单示例,但仍然是同样的问题。

奇怪的是,字符串函数 containstranslate 工作得很好。

这是我的简单 XSLT 样式表:

<?xml version='1.0' encoding='utf-8'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:fo="http://www.w3.org/1999/XSL/Format" version="2.0">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">

    <xsl:value-of select="system-property('xsl:version')" />
    <xsl:value-of select="system-property('xsl:vendor')" />
    <xsl:value-of select="matches('abracadabra', 'bra')"/> <!-- gives error-->
    <xsl:value-of select="replace('abracadabra', 'bra', '*')"/><!-- gives error-->
    <xsl:value-of select="translate('abracadabra','ab','34')"/><!-- works fine-->
    <xsl:value-of select="contains('abracadabra', 'bra')"/><!-- works fine-->
    </xsl:template>
    </xsl:stylesheet>

无论我的 XML 输入如何,这些都应该有效。 任何人都可以建议这里出了什么问题以及如何解决这个问题吗?

Oracle's XML Developer's Kit (12c Release 1) only partially supports XSLT 2.0. Unfortunately, fn:matches and fn:replace are not supported:

Some features of these specifications are not supported in the current release:

  • The Schema Import and Static Typing features are not supported, but the XML Schema built-in types specified by the XPath 2.0 Datamodel
    are supported.
  • The schema-element and schema-attribute nodetests are not supported.
  • The XSLT instruction xsl:number uses XSLT 1.0 semantics and syntax.
  • The use-when standard attribute is not supported.
  • The processor does not honor the attribute of required on xsl:param.
  • Tunnel parameters are not supported.
  • Regular expression instructions are not supported in XSLT.
  • The XPath 2.0 functions fn:tokenize, fn:matches, and fn:replace are not supported.
  • format-dateTime, format-date, and format-time functions are not supported.
  • The content model for xsl:attribute, xsl:comment, xsl:message and the way to compute key values of xsl:key and xsl:sort are still 1.0 behavior.
  • attribute [xsl:]inherit-namespaces for xsl:copy, xsl:element, and literal result elements is not supported.

这种部分支持是否证明从

返回 2.0 是合理的
<xsl:value-of select="system-property('xsl:version')" />

这个问题很有趣。