Validation appears to not recognize substitutionGroup in XSD

This should cover W3C XML Schema, Relax NG and DTD related problems.
solomono
Posts: 11
Joined: Tue Apr 05, 2005 7:46 pm

Validation appears to not recognize substitutionGroup in XSD

Post by solomono » Thu Apr 07, 2005 7:35 pm

Hi,
I am using the eclipse plugin in Eclipse 3.1 M5a
I have some XML that was validated sucessfully in Stylus Studio

here is the instance doc fragment
<core:components>
<core:ComponentType core:name="DefaultValidationPolicy"
core:schemaType="core:DefaultValidationPolicy"
core:extends=""
core:singleton="true">
<core:rolesImplemented>
<core:role>core:ValidationPolicy</core:role>
</core:rolesImplemented>
</core:ComponentType>
<core:ComponentType core:name="DefaultCachePolicy"
core:schemaType="core:DefaultCachePolicy"
core:extends=""
core:singleton="true">
<core:rolesImplemented>
<core:role>core:CachePolicy</core:role>
</core:rolesImplemented>
<core:defaultInstance xsi:type="core:DefaultCachePolicy">
<core:cacheInfo core:subject="core:RuntimeManager"
core:timeOutFrequency="-1"
core:maximumSize="-1"
core:loadAtStartup="false"/>
</core:defaultInstance>
</core:ComponentType>
</core:components>


here is the relevent xsd fragments
<xsd:element name="components" type="core:ComponentTypeCollection"/>

<xsd:complexType name="ComponentTypeCollection">
<xsd:complexContent>
<xsd:extension base="core:Collection">
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="Type" type="Type"/>
<xsd:element name="Include" type="Include"/>
</xsd:choice>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:element name="Type" type="Type"/>
<xsd:complexType name="Type" abstract="true"
core:javaClassName="com.eudoxus.metadata.EudoxusType"
core:javaInterfaceName="com.eudoxus.metadata.IEudoxusType">
<xsd:complexContent>
<xsd:extension base="core:Component">
<xsd:attribute name="schemaType" use="required" type="core:EncodedSchemaType"/>
<xsd:attribute name="name" use="required" type="xsd:Name"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:element name="ComponentType" type="ComponentType"
substitutionGroup="Type"/>
<xsd:complexType name="ComponentType"
core:javaInterfaceName="com.eudoxus.metadata.IComponentType"
core:javaClassName="com.eudoxus.metadata.ComponentType">
<xsd:complexContent>
<xsd:extension base="core:Type">
<xsd:sequence>
<xsd:element name="rolesImplemented" type="EncodedRoleTypeCollection"/>
<xsd:element name="defaultInstance" minOccurs="0" type="xsd:anyType"/>
</xsd:sequence>
<xsd:attribute name="singleton" core:javaFieldName="isSingleton" type="xsd:boolean"/>
<xsd:attribute name="extends" use="required" core:javaFieldName="superType" type="EncodedComponentType"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

Note that componentType elements has a substitutionGroup of Type

The error is cvc-complex-type-2.4.a: Invalid content was found starting with element ComponentType
One of {"urn://com.eudoxus/Core":Type, "urn://com.eudoxus/Core": Include"} was expected.

Note however that the element ComponentType has a substutionGroup of Type

I am doing somethng wrong. This worked in StylusStudio, and my XML documents are full of pattern.
Thanks
Solomon

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Fri Apr 08, 2005 4:20 pm

Hi Solomon,

The content model for the core:components elements contains a core:Type element indeed but that is a local element as you define it with element/@name. It is not a reference to the global core:Type element, you should use element/@ref to refer to the global element. The core:ComponentType can substitute the global core:Type element but not the local one, thus the error.

Best Regards,
George

solomono
Posts: 11
Joined: Tue Apr 05, 2005 7:46 pm

Post by solomono » Fri Apr 08, 2005 8:17 pm

Hi George
I changed the definition of the ComponentType element in components content model to <element ref="Type"> so that it refers to global element.
That solved the problem and taught me some of the finer points of xsd.
What I have seen so for in this product is terrific. OxygenXML can certainly look forward to another sale from me.
Thank you very much
Solomon

Post Reply