1

我有包含 xsl 函数的 schematron 文件。

我收到此错误:“在命名空间 localFunctions 中找不到函数 functionName”

这是我的schematron代码:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" 
    xmlns:sch="http://purl.oclc.org/dsdl/schematron"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fct="localFunctions"
    queryBinding="xslt2" >

<ns prefix="gl-plt" uri="http://www.xbrl.org/int/gl/plt/2010-04-16" />
<ns prefix="gl-cor" uri="http://www.xbrl.org/int/gl/cor/2006-10-25" />
<ns prefix="gl-bus" uri="http://www.xbrl.org/int/gl/bus/2006-10-25" />
<ns prefix="xbrli" uri="http://www.xbrl.org/2003/instance" />
<ns prefix="edefter" uri="http://www.edefter.gov.tr" />
<ns prefix="fct" uri="localFunctions" />

<title></title>

<!-- <gl-cor:accountingEntries> elemanı bir <gl-cor:entityInformation> elemanı içermelidir.  -->
<pattern id="accountingentries">
    <rule context="/edefter:defter/xbrli:xbrl/gl-cor:accountingEntries">
        <let name="accoundMainIdList" value="gl-cor:entryHeader/gl-cor:entryDetail[1]/gl-cor:account/normalize-space(gl-cor:accountMainID)"/>
        <assert test="fct:isSorted($accoundMainIdList)">Büyük defterde hesaplar, ana hesap numarası bazında sıralı olmalıdır.</assert>
     </rule>        
</pattern>

<xsl:function name="fct:isSorted" as="xs:boolean">
<xsl:param name="accoundMainIdList" as="xs:string*"/>
<xsl:variable name="sortedAccountMainIdList" as="xs:string*">
  <xsl:for-each select="$accoundMainIdList">
    <xsl:sort/>
    <xsl:value-of select="."/>
  </xsl:for-each>
</xsl:variable>
<xsl:variable name="s1">
  <xsl:value-of select="string-join($accoundMainIdList,'|')"/>
</xsl:variable>
<xsl:variable name="s2">
  <xsl:value-of select="string-join($sortedAccountMainIdList,'|')"/>
</xsl:variable>
<xsl:choose>
  <xsl:when test="$s1 = $s2">
    <xsl:value-of select="true()"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="false()"/>
  </xsl:otherwise>
</xsl:choose>
</xsl:function>

</schema>

为什么在命名空间中找不到 isSorted xsl 函数?

4

2 回答 2

2

我假设您知道运行 Schematron 模式的传统方法是使用 XSLT 处理它们以生成可以针对您的 XML 实例执行的 XSLT 样式表。

在 github 上查看 XRouters Schematron 项目正在使用来自http://www.schematron.com/的标准 XSLT 样式表的非常旧版本。这些是 XSLT 1.0 样式表,不能生成 XSLT 2.0 样式表。

xsl:function您尝试使用的元素是 XSLT 2.0 的一部分。鉴于您的工具正在生成 XSLT 1.0,您的 XSLT 2.0 函数似乎不太可能运行。

如果您想尝试一种可能更成功的方法,我建议您从http://saxon.sf.net/获取 Saxon HE(.net 版本)的副本。然后,您可以构建一组简单的 XSLT 转换,让您有更多机会获得想要的东西。

于 2014-06-20T13:35:07.277 回答
0

I think @Nic's answer is in the right direction, but missed the mark.

Although the standard way of running schematron schemas against XML documents is to convert them to XSLT, that approach has a number of drawbacks (speed and having validation report you can process programmatically are two primary ones).

The XRouter SchemaTron is a native .NET implementation of ISO schematron. It doesn't convert the schematron schemas to XSLT stylesheets -- it parses them in memory and then processes each pattern/rule/assert to detect violations.

The problem is certainly rooted in a lack of XSLT2 support, but is not related at all to XSLT schematron stylesheets (they arent used, and are included in the project only as reference). Schematron specification doesn't require XSLT2 (or XPATH2) -- it leaves the query language to the schematron rules file. The branch you were using was probably the one delivering XPATH2 support via "Lightweight XPath2 for .NET", which doesn't support XSLT2.

I recommend using the branch of the project integrated with XmlPrime, with supports XSLT2. We're using that version with great success.

于 2014-08-04T10:45:08.743 回答