Possible Bug with Saxon Schema Validation

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
fsteimke
Posts: 58
Joined: Tue Jan 01, 2013 3:19 pm

Possible Bug with Saxon Schema Validation

Post by fsteimke » Tue Feb 16, 2021 6:32 pm

Hi,
i'd like to construct a XML Schema C (XSD Version 1.1), which includes an XML Schema B (without any version attributes) and imports another XML Schema A (XSD Version 1.1). The Idea is that i can extend a complexType from B by an xs:assert Element, which, in its test condition, references a Type from the imported Schema A.

When i validate the Schema C, which imports A and includes B
  • there is no error with XERCES;
  • But SAXON reports an Error: "Atomic type ns1:Token3 exists, but its target namespace has not been imported in the static context"
There must be a Bug in either XERXES or SAXON. I don't know which. Since there is an explicit import Statement for the Namespace ns1, i'd guess that XERXES is right and SAXON is wrong. But maybe there are XML Schema Version conflicts.

This happens in XML Editor 22.1, build 2020100710 on Windows.

Schema A (XSD Version 1.1) defines the simple Type:

Code: Select all

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
    vc:minVersion="1.1" targetNamespace="http//www.namespace.1" xmlns:ns1="http//www.namespace.1">
    <xs:simpleType name="Token3">
        <xs:restriction base="xs:token">
            <xs:length value="3"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
Schema B (without Version Attributes) defines the complex Type:

Code: Select all

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
    targetNamespace="http://www.namespace.2" xmlns:ns2="http://www.namespace.2">
    <xs:complexType name="TypeB">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="child" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
Schema C (XSD Version 1.1) imports A and includes B, because i'd like to extend a Type from B. But Saxon says that the target namespace from Schema A has not been imported in the static context.

Code: Select all

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
    vc:minVersion="1.1" targetNamespace="http://www.namespace.2" xmlns:ns1="http//www.namespace.1"
    xmlns:ns2="http://www.namespace.2">

    <xs:import namespace="http//www.namespace.1" schemaLocation="schemaA-11.xsd"/>
    <xs:include schemaLocation="SchemaB.xsd"/>

    <xs:complexType name="ProfiledTypeB">
        <xs:complexContent>
            <xs:extension base="ns2:TypeB">
                <xs:assert test="ns2:child castable as ns1:Token3"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    
</xs:schema>
Thanks in advance,
Frank Steimke

tavy
Posts: 276
Joined: Thu Jul 01, 2004 12:29 pm

Re: Possible Bug with Saxon Schema Validation

Post by tavy » Wed Feb 17, 2021 10:28 am

Hello Frank,

Thanks for your feedback.
Yes, it seems to be a problem with the Saxon validation in an assert. If the type "ns1:Token3" is set as an element type, no problem is reported. Therefore, it seems that the problem occurs when referring the type in an assert element.

I reported the problem at Saxon: https://saxonica.plan.io/issues/4911

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

fsteimke
Posts: 58
Joined: Tue Jan 01, 2013 3:19 pm

Re: Possible Bug with Saxon Schema Validation

Post by fsteimke » Wed Feb 17, 2021 7:21 pm

just saw that this has been checked by Mr. Kay from Saxonica with the result that this is not a Bug.
It is not, as i thought, a Question of different Schema Versions. Instead it's simply a limitation of xs:assert.

Well, that means that we have to find a different solution. Maybe a combination of XML Schema 1.0 for Structure and Schematron for additional Constraints. Thank you very much for clarification.

Sincerely,
Frank Steimke

Post Reply