- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 27 Mar 2002 13:17:34 +0000
- To: "Dent, Andrew" <aed5@cdc.gov>
- CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Andrew, > Quick question: The following code validates in XMLSpy, but using > MSXML4 (in VB) raises the following error: > > Invalid particle derivation by restriction > Base Type {http://www.opengis.org/gml}GeometryCollectionType > Derived Type {http://www.opengis.org/gml}MultiLineStringType The relevant types from your code are: <complexType name="MultiLineStringType"> <complexContent> <restriction base="gml:GeometryCollectionType"> <sequence> <element name="lineStringMember" maxOccurs="unbounded"> <complexType> <sequence> <element ref="gml:LineString"/> </sequence> </complexType> </element> </sequence> </restriction> </complexContent> </complexType> and: <complexType name="GeometryCollectionType"> <complexContent> <extension base="gml:AbstractGeometryCollectionBaseType"> <sequence> <element ref="gml:geometryMember" maxOccurs="unbounded"/> </sequence> </extension> </complexContent> </complexType> which is in turn based on: <complexType name="AbstractGeometryCollectionBaseType" abstract="true"> <complexContent> <restriction base="gml:AbstractGeometryType"> <attribute name="gid" type="ID" use="optional"/> <attribute name="srsName" type="anyURI" use="required"/> </restriction> </complexContent> </complexType> The GeometryCollectionType therefore has a content of one or more gml:geometryMember elements. You are attempting to derive this to a MultiLineStringType that contains one or more gml:lineStringMember elements. The basic rule that you always have to follow when deriving by restriction is that an element that is valid according to the derived type *must* also be valid according to the base type. In other words, all the elements of the type MultiLineStringType must be valid according to the GeometryCollectionType. But that's the not the case in your schema: an element that contains a gml:lineStringMember element isn't a valid GeometryCollectionType element. This is why the derivation by restriction is failing. If you want the derivation by restriction to cause a change in the name of the child element, then you need to use substitution groups. The gml:geometryMember element needs to be declared at the top level of the schema (as it is already). The gml:lineStringMember element also needs to be declared at the top level of the schema, and reference the gml:geometryMember element to say that it is part of its substitution group: <xs:element name="lineStringMember" substitutionGroup="gml:geometryMember" ... /> Also note that to make this legal, the gml:lineStringMember element has to have a type that's an explicit restriction of the gml:geometryMember element's type. Alternatively, if you don't want the types of gml:lineStringMember and gml:geometryMember to be related, you can declare the GeometryCollectionType to contain any elements in the GML namespace: <complexType name="GeometryCollectionType"> <complexContent> <extension base="gml:AbstractGeometryCollectionBaseType"> <sequence> <any namespace="##targetNamespace" maxOccurs="unbounded" /> </sequence> </extension> </complexContent> </complexType> though obviously that might cause problems elsewhere. Either way, your hierarchies probably need reworking a bit. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Wednesday, 27 March 2002 08:17:35 UTC