W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2007

Re: optional, but at least one required

From: Pete Cordell <petexmldev@tech-know-ware.com>
Date: Thu, 11 Oct 2007 09:31:42 +0100
Message-ID: <002b01c80be1$2c8e2780$5d00a8c0@Codalogic>
To: "Virginia Wiswell" <vwiswell@verizon.net>
Cc: <xmlschema-dev@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:00 GMT