Re: optional, but at least one required

To be pedantic, removing the second <xsd:element ref="a"/> prevents the 
Unique Particle Attribution violation for _a_.  We then need to work around 
this change by adding minOccurs="0" to element b so we allow what we want.

:-),

Pete.
----- Original Message ----- 
From: "Virginia Wiswell" <vwiswell@verizon.net>
To: "Pete Cordell" <petexmldev@tech-know-ware.com>; "Virginia Wiswell" 
<vwiswell@verizon.net>
Cc: <xmlschema-dev@w3.org>
Sent: Thursday, October 11, 2007 2:35 AM
Subject: Re: optional, but at least one required


>
> So the minOccurs="0" on element b prevents the Unique Particle Attribution 
> violation for b?
>
> This is perfect, Pete. Thanks so much for helping me out.
>
> On Wed, 10 Oct 2007 19:22:51 +0100
>  "Pete Cordell" <petexmldev@tech-know-ware.com> wrote:
>>
>> Hi Virginia,
>>
>> Your schema should indeed yield a Unique Particle Attribution violation. 
>> The reason is that when a parser reads element a, it is not immediately 
>> obvious whether it corresponds to the first definition of a or the 
>> second.
>>
>> You can get around this by changing your schema to:
>>
>>  <xsd:element name="parent">
>>   <xsd:complexType>
>>    <xsd:choice>
>>      <xsd:sequence>
>>        <xsd:element ref="a"/>
>>        <xsd:element ref="b" minOccurs="0"/>
>>      </xsd:sequence>
>>      <xsd:element ref="b"/>
>>    </xsd:choice>
>>   </xsd:complexType>
>>  </xsd:element>
>>
--
=============================================
Pete Cordell
Codalogic
for XML Schema to C++ data binding visit
 http://www.codalogic.com/lmx/
=============================================

Received on Thursday, 11 October 2007 08:32:12 UTC