我试图在我的XSLT样式表中使用这两个字符串函数(matches和replace).但在运行时我得到以下错误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)
Run Code Online (Sandbox Code Playgroud)
xslt处理器版本是2.0,它应该支持这些功能,如http://www.w3schools.com/xsl/func_systemproperty.asp.
我还尝试复制w3org(http://www.w3.org/TR/xpath-functions/#func-matches)上列出的简单示例,但问题仍然存在.
奇怪的是,字符串功能contains和translate工作正常.
这是我的简单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 …Run Code Online (Sandbox Code Playgroud)