Re: Circular types in XML Schemas

Hi all,

>> What does the XML Schema specification says about infinite recursive
>> types, i.e. the ones that do not have a minOccurs="0" as a loophole?
> 
> As far as I know, nothing. I think that it's quite difficult for a
> schema validator to test for this kind of unsatisfiable schema, though
> you'd find out soon enough that there was something wrong if you
> tested the schema against any instance document!

After reading this thread, I still don't see *why* the specification 
would prevent circular model groups only when reused as a "direct model 
group particule" (at any depth), but not when such a group is 
"indirectly reused" through an element declaration.

For example, if the model group definition below is invalid (note the 
minOccurs = 0) according to the "Model Group Correct" constraint 
preventing circular groups:

<xs:group name="error">
   <xs:sequence>
     ...
     <xs:group ref="ms:error" minOccurs="0"/>
   </xs:sequence>
</xs:group>

Then, I don't see why the other one below would be a valid one.

<xs:group name="error">
   <xs:sequence>
     ...
     <xs:element name="error">
       <xs:complexType>
         <xs:group ref="ms:error" />
       </xs:complexType>
     </xs:element>
   </xs:sequence>
</xs:group>

I do see an interest in using recursive types when ensuring that a 
minOccurs=0 or via a nillable property defined correctly, but if 
recursive types are allowed, I think there is an inconsistency of
treatment with "pure" model groups in the XSD spec.

> In general, the schema component constraints don't test every thing
> you could do to make it impossible for an instance to validate against
> your schema. For example, it's very easy to create identity
> constraints that are unsatisfiable (because they try to select nodes
> that don't exist), or to create simple types that have no valid
> lexical representations (because you use a pattern that doesn't match
> the base type, for example). It's therefore essential, during
> development, to test schemas against instance document that you know
> are valid.

I agree, but I think it would be useful if the specification could make 
the distinction between schema constraints that must be enforced by an
instance validator and other that would be more of the responsability of 
the person writing the schema or the responsability of a schema design 
validator.

Regards,
Jerome Louvel.

Received on Saturday, 4 May 2002 06:40:11 UTC