Next in thread → Next in month →

Re: [xml-dev] Ambiguous Content Models

From
<>
To
Eric van der Vlist <>
Date
2003-10-04T09:37:39Z
ID
<>
Thread
Re: [xml-dev] Ambiguous Content Models
Eric van der Vlist <> writes:

> On Fri, 2003-10-03 at 12:42, Max Chappell wrote:
>
>> Does anybody have any comments on the validity of the above? 
>
> The IBM Schema Quality Checker is right...
>
> If you have several "Person" elements in your instance document, a
> schema processor can't immediately tell if they belongs to the first
> sequence, to the xs:element that follows or to the second sequence and
> that's violating the restrictions of W3C XML Schema.
>
> Furthermore, your schema is not capturing "they want any element of the
> three elements in any order, as many or as few times as they want" :-)
> ...
>
> The usual way to translate "any element of the three elements in any
> order, as many or as few times as they want" in WXS is through
> xs:choice:
>
>     <xs:choice minOccurs="0" maxOccurs="unbounded">
>         <xs:group ref="tns:GenericElements"/>
>         <xs:element name="Person" type="tns:Person"/>
>         <xs:element name="Location" type="tns:Loc"/>
>     </xs:choice>
>
> That doesn't capture the fact that "they also want at least one 
> person element to be present every time" but I don't see how you can
> capture this using WXS alone.

Sure, it's easy -- you want the schema equivalent of

 <!ELEMENT x ((a|b)*,c,(a|b|c)*)>

  <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="tns:GenericElements"/>
        <xs:element name="Location" type="tns:Loc"/>
    </xs:choice>
    <xs:element name="Person" type="tns:Person"/>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:group ref="tns:GenericElements"/>
        <xs:element name="Person" type="tns:Person"/>
        <xs:element name="Location" type="tns:Loc"/>
    </xs:choice>
  </xs:sequence>

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                      Half-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: 
		     URL: http://www.ltg.ed.ac.uk/~ht/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]
Next in thread → Next in month →