第二次使用 schema-element() 更新 XSLT 以查找在没有名称空间的模式中定义的节点

Second update XSLT using schema-element() to find nodes defined in a schema with no namespace

我正在使用 XML 编辑器 18.1 编写和 运行 XSL 样式-sheet 下面:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="xs" version="2.0">   

<xsl:import-schema schema-location="orig.xsd"/>

<xsl:template match="schema-element(orig)">
...
</xsl:template>

</xsl:stylesheet>

<orig> 被定义为以下无命名空间架构中的顶级元素:

<?xml version="1.1" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
    xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xi="http://www.w3.org/2001/XInclude"
    vc:minVersion="1.1">

    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml_namespace.xsd"/>


<xs:element name="orig">
    <xs:complexType>
        <xs:sequence>
            ...
        </xs:sequence>
        <xs:attributeGroup ref="pointer_attributes"/>
    </xs:complexType>
</xs:element>

stylesheet编译过程中,Saxon-EE 9.6.0.7 returns报错如下:

System ID: Main validation file: ... Engine name: Saxon-EE 9.6.0.7 Severity: fatal Description: XPST0008 XSLT Pattern syntax error at char 26 on line 12 in {schema-element(orig)}: There is no declaration for element in an imported schema Start location: 12:26 URL: http://www.w3.org/TR/xpath20/#ERRXPST0008

编译适用于以下架构:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> 

<xs:element name="orig">
    <xs:complexType>
       <xs:sequence>
           <xs:element name="nested_element" type="xs:string"/>
       </xs:sequence>
    </xs:complexType>
</xs:element>

</xs:schema>

但是,一旦我添加 vc:minVersion="1.1",错误又发生了。

问题几乎肯定会出现,因为 Saxon 配置为 运行 作为 XSD 1.0 处理器而不是 XSD 1.1 处理器。默认配置是 XSD 1.0.

您说您正在使用 XML Editor 18.1(大概是 oXygen XML Editor 18.1)。所以你需要在 oXygen 中设置这个配置参数。在"Configure Transformation Scenario"中,首先selectSaxon-EE作为transformer引擎;然后单击代表 "Advanced Configuration Options" 的图标。此表单的底部是一个标记为 "Saxon-EE specific options" 的部分,包括 select XSD 1.0 或 XSD 1.1.

的单选按钮