derivation-ok-restriction : The particle of the type is not a valid restriction of the particle of the base

StackOverflow https://stackoverflow.com/questions/20490184

  •  30-08-2022
  •  | 
  •  

Question

I defined the ComplexType bellow :

<xs:element name="abstractForm" type="abstractFormType" abstract="true"/>
<xs:complexType name="abstractFormType" abstract="true">
    <xs:sequence>
        <xs:any minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id-form" type="xs:NCName"/>
    <xs:attribute name="select"/>
    <xs:anyAttribute/>
</xs:complexType>

But after that in the code, every time I add a ComplexType I have this error : derivation-ok-restriction : The particle of the type is not a valid restriction of the particle of the base.

Exemple :

<xs:element name="abstractNewForm" type="abstractNewFormType" abstract="true"
        substitutionGroup="abstractForm"/>
<xs:complexType name="abstractNewFormType" abstract="true">
    <xs:complexContent>
        <xs:restriction base="abstractFormType">
            <xs:sequence>
                <xs:sequence>
                    <xs:element name="customize" minOccurs="0" type="abstractCustomizeType"/>
                </xs:sequence>
                <xs:sequence>
                    <xs:element name="positions" minOccurs="0" type="abstractPositionsType"/>
                </xs:sequence>
            </xs:sequence>
            <xs:attribute name="id-form" type="xs:NCName" use="required"/>
            <xs:attribute name="select"/>
            <xs:anyAttribute/>
            </xs:restriction>
    </xs:complexContent>
</xs:complexType>

Someone has an idea ? :)

Was it helpful?

Solution

Saxon accepts this as a valid restriction, but with a warning:

Warning: on line 20 of test.xsd:
  There is no global element declaration named {customize}, so the strict wildcard in the
  base type can never be satisfied
Warning: on line 23 of test.xsd:
  There is no global element declaration named {positions}, so the strict wildcard in the
  base type can never be satisfied

Remember that xs:any defaults to processContents="strict", meaning that the only elements that can appear here are elements that have a global declaration in the schema. And since "customise" and "positions" don't have global declarations, they don't satisfy this condition. I would have to do some research to work out why Saxon puts this out as a warning rather than an error. Whatever schema processor you are using, it has taken a different interpretation. Mind you, Saxon tests subsumption the XSD 1.1 way, even if XSD 1.1 is not enabled, because there are bugs in the XSD 1.0 spec in this area: but some processors have chosen to be strictly conformant, and implement it bugs and all.

I would recommend making "customise" and "positions" into global element declarations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top