Search code examples
xmlxsltxsdxslt-2.0saxon

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


I'm using XML Editor 18.1 to write and run XSL style-sheet below:

<?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> is defined as a top level element in the no namespace schema below:

<?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>

During the stylesheet compilation, Saxon-EE 9.6.0.7 returns the error message below:

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

Compilation is fine with the schema below:

<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>

However, as soon as I add vc:minVersion="1.1" the error is occurring again.


Solution

  • The problem is almost certainly arising because Saxon is configured to run as an XSD 1.0 processor rather than as an XSD 1.1 processor. The default configuration is XSD 1.0.

    You say that you are using XML Editor 18.1 (that's presumably oXygen XML Editor 18.1). So you need to set this configuration parameter within oXygen. In "Configure Transformation Scenario", first select Saxon-EE as the transformer engine; then click on the icon representing "Advanced Configuration Options". Towards the bottom of this form is a section labelled "Saxon-EE specific options", including a radio button to select XSD 1.0 or XSD 1.1.