0
votes

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.

1
Are conditions in w3.org/TR/xpath-30/#id-schema-element-test fulfilled? You really should show us minimal but complete samples of XSLT, XSD, we need to see whether the schema has a top level xsl:element name="orig".Martin Honnen
Sorry, I forgot to mention, yes, <orig> is a top-level element (it can be used as a root element for an instance of this schema). I'm trying to debug the XSLT with a simple stylesheet with only the xsl:import-schema and the schema-element(orig) template, but Saxon still tell me that orig is not declared in the schema.colibrisson
As I said, if you want others here to help then it is best to post minimal but complete samples of the code to allow us to reproduce the problem, as you use Saxon you might also want to explain how you try to run the schema-aware transformation exactly (e.g. inside oXygen or from the command line showing the exact command line).Martin Honnen
What namespace declarations are present in the stylesheet? We really need full context to help you debug this.Michael Kay
I updated the question with my code.colibrisson

1 Answers

2
votes

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.