0

I have been dealing with a problem that although seems to be relatively simple, been taking a lot of my time with no success. I am creating a profile of Geographic Markup Language (GML), similar to CityGML. However, I keep getting the error "type definition of element {element} is not validly derived from that of its substitution group affiliation {element}" despite the fact to me everything looks ok with the schemas.

The way I designed the schemas, in the "Flood.xsd", I should be able to use"_floodObject" as a substitute of "_urbanObject". However I get the error when I try to validate my "flood.xsd" schema: "The type definition of element '_FloodObject' is not validly derived from that of its substitution group affiliation '_UrbanObject'."

Can you guide me what I'm doing wrong here? Many thanks and looking forward to receiving comments to resolve the issue.

Sam

My Root ( i call it CORE) schema is as follows:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:gml="http://www.opengis.net/gml/3.2" 
  xmlns="http://localhost/schemas/1.0" 
  xmlns:mtl="http://localhost/schemas/Material/1.0" 
  targetNamespace="http://localhost/schemas/1.0" 
  elementFormDefault="qualified" 
  attributeFormDefault="unqualified" 
  version="1.0">
  <xs:annotation>
    <xs:documentation />
  </xs:annotation>
  <xs:import namespace="http://www.opengis.net/gml/3.2" 
    schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
  <xs:import namespace="http://localhost/schemas/Material/1.0" 
    schemaLocation="http://localhost/Schemas/Schema/MaterialDomain.xsd"/>

    <!-- ======================UrbanFloodModel (root element) =========================================== -->
  <xs:element name="UrbanFloodModel" 
    type="UrbanFloodModelType" 
    substitutionGroup="gml:AbstractFeatureCollection"/>
  <!-- ======================UrbanFloodModelType=========================================== -->
  <xs:complexType name="UrbanFloodModelType">
    <xs:complexContent>
      <xs:extension base="gml:AbstractFeatureCollectionType">
        <xs:sequence>
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="MaterialObjectMember" 
                        type="mtl:MaterialObjectMemberType"/>
            <xs:element name="UrbanObjectMember" 
                        type="UrbanObjectMemberType"/>
            <xs:element name="SpatialStructureObjectMember" 
                        type="SpatialStructureObjectMemberType"/>
          </xs:choice>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <!-- ======================UrbanObjectMemberType=========================================== -->
  <xs:complexType name="UrbanObjectMemberType">
    <xs:sequence>
      <xs:element ref="_UrbanObject" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>
  <!-- ======================_UrbanObject=================================================== -->
  <xs:element name="_UrbanObject" 
              abstract="true" 
              type="AbstractUrbanObjectType" 
              substitutionGroup="gml:AbstractFeature" />
  <!-- ======================AbstractUrbanObjectType======================================== -->
  <xs:complexType name="AbstractUrbanObjectType" abstract="true">
    <xs:annotation>
      <xs:documentation>Type describing the abstract superclass of urban objects.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="gml:AbstractFeatureType">
        <xs:sequence>
          <xs:element name="ContainedInSpatialStructures">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="SpatialStructureObjectReference" 
                            type="xs:string" 
                            maxOccurs="unbounded"/>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <!-- ======================SpatialStructureObjectMemberType======================================== -->
  <xs:complexType name="SpatialStructureObjectMemberType">
    <xs:annotation>
      <xs:documentation>Type describing the abstract superclass of urban objects.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="gml:AbstractFeatureType">
        <xs:sequence>
          <xs:element name="ContainedUrbanObjects" minOccurs="0">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="UrbanObjectReference" 
                            type="xs:string" 
                            minOccurs="1" 
                            maxOccurs="unbounded"/>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
        <xs:attribute name="referenceSpatialStructureElementID" 
                      type="xs:string" 
                      use="required"/>
        <xs:attribute name="spatialStructureElementType" 
                      type="xs:int" 
                      use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

and my "Flood.xsd" (importing the above schema as "core") looks like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:gml="http://www.opengis.net/gml/3.2" 
  xmlns:core="http://localhost/schemas/1.0" 
  xmlns="http://localhost/schemas/Flood/1.0" 
  targetNamespace="http://localhost/schemas/Flood/1.0" 
  elementFormDefault="qualified" version="1.0">
    <xs:import namespace="http://www.opengis.net/gml/3.2" 
      schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
    <xs:import namespace="http://localhost/schemas/1.0" 
      schemaLocation="http://localhost/Schemas/Schema/UrbanFloodBase.xsd"/>

  <!-- ==================================FloodObject======================================== -->
  <xs:element name="_FloodObject" 
              type="AbstractFloodObjectType" 
              abstract="true" 
              substitutionGroup="core:_UrbanObject"/>

  <xs:complexType name="AbstractFloodObjectType">
    <xs:annotation/>
    <xs:complexContent>
      <xs:extension base="core:AbstractUrbanObjectType"/>
    </xs:complexContent>
  </xs:complexType> 
</xs:schema>
C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65

1 Answers1

1

It doesn't look to me as if you are doing anything wrong. Both Saxon and Xerces tell me the schema document is valid (although Saxon does warn that the GML schema documents include themselves recursively).

What XSD validator are you using?

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65