W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2004

Re: XML Schema Question

From: Mik Lernout <mik@futurestreet.org>
Date: Mon, 23 Aug 2004 16:17:42 +0200
Message-ID: <4129FC86.1000409@futurestreet.org>
To: Michael Kay <mhk@mhk.me.uk>
CC: "'Jeni Tennison'" <jeni@jenitennison.com>, "'Asleson, Ryan'" <asleson@BIWORLDWIDE.com>, xmlschema-dev@w3.org

Just a little sideremark...

We shouldn't be offering these kind of solutions to novices in XMLSchema 
or people who are in the process of (re)defining their schemas.

There is a very good reason why ordering is preferred to non-ordering 
and it is the "XML Schema"-way to do things.
All of the solutions offered here are overcomplicating implementations 
and confusing users, pushing them to other validation technologies or 
wrecking the validation performance.

XMLSchema can be clean and simple and that's how we should guide 
potential users...

What do you people think?

Mik



Michael Kay wrote:

>>This is the most frequent of FAQs. It can't be done in XML Schema.
>>    
>>
>
>Actually, I think someone did discover a way of doing it. You can use a
>choice as in (2) below, and then use a uniqueness constraint to ensure there
>is only one father and only one mother. Under the element declaration for
>family, you add:
>
><xs:unique name="one-father">
>  <xs:selector xpath="."/>
>  <xs:field xpath="father"/>
></xs:unique>
>
>This will cause a validation error if a the xs:field expression selects more
>than one node, that is, if a family has more than one father.
>
>Michael Kay
>Saxonica Limited
>www.saxonica.com
>
>  
>
>>Your options are:
>>
>>1. Constrain the order as in your current schema, and use a simple
>>transformation to transform the any-order documents into the
>>constrained-order documents, which you can then validate.
>>
>>2. Use a content model with no constraints on occurrence, as in:
>>
>>  <xs:choice minOccurs="0" maxOccurs="unbounded">
>>    <xs:element ref="father" />
>>    <xs:element ref="mother" />
>>    <xs:element ref="son" />
>>    <xs:element ref="daughter" />
>>    <xs:element ref="pet" />
>>  </xs:choice>
>>
>>and add supplementary Schematron rules to constrain the occurrence of
>>each of the elements. The Schematron rules can be processed in a
>>separate step.
>>
>>3. Switch to using RELAX NG, where you can do:
>>
>>  <interleave>
>>    <optional><ref name="father" /></optional>
>>    <optional><ref name="mother" /></optional>
>>    <zeroOrMore><ref name="son" /></zeroOrMore>
>>    <zeroOrMore><ref name="daughter" /></zeroOrMore>
>>    <zeroOrMore><ref name="pet" /></zeroOrMore>
>>  </interleave>
>>
>>or, in compact syntax:
>>
>>  father? & mother? & son* & daughter* & pet*
>>
>>Cheers,
>>
>>Jeni
>>
>>---
>>Jeni Tennison
>>http://www.jenitennison.com/
>>
>>
>>
>>    
>>
>
>
>  
>
Received on Monday, 23 August 2004 14:17:58 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:10 UTC