xmlxsdxsd-validationxml-validationaltova

Unique Particle Attribution error


Aim: I am having an existing standard XSD called Schema1.xsd. I want to extend the complexType("tElementWithIDAndName") of Schema1.xsd in complexType("TVDSection") of Schema2.xsd.

When i try to validate the Schema2.xsd in Altova XMLSpy/oXygen xml editor, I am getting the following error:

Error: [Xerces] cos-nonambig: "http://www.mySchema.com/Generic/1":element1 and WC[##other:"http://www.mybasic.com/1",""] (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.

Schema1.xsd:

            <?xml version="1.0" encoding="UTF-8"?>
            <xs:schema xmlns="http://www.mybasic.com/1" 
                       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                       xmlns:xml="http://www.w3.org/XML/1998/namespace"  
                       targetNamespace="http://www.mybasic.com/1" 
                       elementFormDefault="qualified" 
                       version="0.1">

                <xs:complexType name="tElementWithIDAndName">
                    <xs:sequence>
                          <xs:element name="additionalName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                          <xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="id" type="xs:ID" use="required"/>
                    <xs:attribute name="name" type="xs:string" use="required"/>
              </xs:complexType>
            </xs:schema>    

Schema2.xsd:

            <?xml version="1.0" encoding="UTF-8"?>
            <xs:schema xmlns="http://www.mySchema.com/Generic/1" 
                       xmlns:xs="http://www.w3.org/2001/XMLSchema"
                       xmlns:myBasic="http://www.mybasic.com/1"
                       targetNamespace="http://www.mySchema.com/Generic/1"
                       elementFormDefault="qualified" version="0.1">

                <xs:import namespace="http://www.mybasic.com/1" schemaLocation="schema.xsd"/>

                <xs:element name="Element1" type="TVDSection"/>
                <xs:complexType name="TVDSection">
                    <xs:complexContent>
                        <xs:extension base="myBasic:tElementWithIDAndName">
                            <xs:sequence>
                                <xs:element name="element1" type="xs:string" minOccurs="0" maxOccurs="unbounded">
                                </xs:element>
                            </xs:sequence>
                        </xs:extension>
                    </xs:complexContent>
                </xs:complexType>
            </xs:schema>

I don't know where/how this is violating unique particle attribution. Please help me to resolve the above issue.


Solution

  • Your content model can be paraphrased as "any number of elements named p:additionalName, followed by any number of elements provided they are not in namespace 'p', followed by any number of elements named q:element1, ". Now, if a q:element1 element is encountered, the validator doesn't know whether to put it in the second group (any number of elements that aren't in namespace 'p') or the third group (anything named q:element1). Hence the ambiguity.

    In XSD 1.1 the spec has been changed so that in this situation, where there is a specific particle and a wildcard particle that both match, the specific particle is always chosen in preference. So one solution is simply to move to XSD 1.1. If you want to stay with XSD 1.0, you need to change the xs:any wildcard so it puts more constraints on the namespace of the allowed elements.