gpt4 book ai didi

java - 为什么 fn :matches and fn:replace throwing parse errors in XSLT 2. 是 0?

转载 作者:数据小太阳 更新时间:2023-10-29 02:23:44 24 4
gpt4 key购买 nike

我试图在我的 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)仅部分支持 XSLT 2.0。不幸的是,fn:matchesfn:replacenot 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')" />

是个有趣的问题。

关于java - 为什么 fn :matches and fn:replace throwing parse errors in XSLT 2. 是 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28990021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com