Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: optional, but at least one required

From: "Virginia Wiswell" <vwiswell@-------.--->
To: "Pete Cordell" <petexmldev@--------------.--->,"Virginia Wiswell" <vwiswell@-------.--->
Date: 10/10/2007 3:35:00 PM
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@t...> 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>
> 
> HTH,
> 
> Pete.
> =============================================
> Pete Cordell
> Codalogic
> for XML Schema to C++ data binding visit
> http://www.codalogic.com/lmx/
> =============================================
> 
> ----- Original Message ----- From: "Virginia Wiswell" 
><vwiswell@v...>
> To: "Michael Kay" <mike@s...>; "'George Cristian Bina'" 
><george@o...>; <vwiswell@v...>
> Cc: <xmlschema-dev@w...>
> Sent: Wednesday, October 10, 2007 7:06 PM
> Subject: Re: optional, but at least one required
> 
> 
>>
>> Michael, you are exactly right. I think I figured it out, though:
>>
>>  <xsd:element name="parent">
>>   <xsd:complexType>
>>    <xsd:choice>
>>      <xsd:sequence>
>>        <xsd:element ref="a"/>
>>        <xsd:element ref="b"/>
>>      </xsd:sequence>
>>        <xsd:element ref="a"/>
>>        <xsd:element ref="b"/>
>>    </xsd:choice>
>>   </xsd:complexType>
>>  </xsd:element>
>>
>> I kept getting a Unique Particle Attribution rule error for 'a' in 
>>Stylus 
>> Studio. I found a post somewhere that said that this was a bug, and 
>>when I 
>> used Sax, it validated just fine.
>>
>> If you have a better way of doing it, I'd love to see it. Thanks so 
>>much 
>> for your help, guys.
>>
>>
>> On Wed, 10 Oct 2007 14:17:28 +0100
>>  "Michael Kay" <mike@s...> wrote:
>>> George, your reading of the requirement is very literal.
>>>
>>> "I have a and b, at least one of them has to appear once AND ONLY 
>>>ONCE." 
>>> My guess at the likely meaning is to accept a|b|ab. But I might be 
>>>wrong.
>>>
>>> Michael Kay http://www.saxonica.com/
>>>
>>>> -----Original Message-----
>>>> From: xmlschema-dev-request@w... 
>>>>[mailto:xmlschema-dev-request@w...] 
>>>> On Behalf Of George Cristian Bina
>>>> Sent: 10 October 2007 08:42
>>>> To: vwiswell@v...
>>>> Cc: xmlschema-dev@w...
>>>> Subject: Re: optional, but at least one required
>>>>
>>>>
>>>> Hi Virginia,
>>>>
>>>> I understand that what you want is
>>>> ab* | a*b
>>>> and you need to write that in a non ambiguous way to be able to 
>>>>write it 
>>>> in XML Schema.
>>>>
>>>> So what we need to accept is
>>>>
>>>> a ab abb abbb ...
>>>> b ab aab aaab ...
>>>>
>>>>
>>>> You can write that as
>>>>
>>>> ((a, (b* | (a+, b))) | b)
>>>>
>>>> Best Regards,
>>>> George
>>>> ---------------------------------------------------------------------
>>>> George Cristian Bina - http://aboutxml.blogspot.com/ <oXygen/> XML 
>>>> Editor, Schema Editor and XSLT Editor/Debugger 
>>>>www.---.com
>>>>
>>>>
>>>> Virginia Wiswell wrote:
>>>> > I have a similar situation that I'm having trouble with. I
>>>> have a and
>>>> > b, at least one of them has to appear once AND ONLY ONCE. a
>>>> must come before b.
>>>> > The examples in this thread allow more than one occurrence
>>>> of a or b.
>>>> >
>>>> > This is my first attempt at customizing a schema and I'm stuck.
>>>> >
>>>> > TIA, Virginia
>>>> >
>>>> >> You need to specify the requirements in a little more detail:
>>>> >>
>>>> >> * are multiple occurrences of a, b, and c allowed?
>>>> >>
>>>> >> * what constraints do you want to impose on the ordering
>>>> of the elements?
>>>> >>
>>>> >> Michael Kay
>>>> >> http://www.saxonica.com/
>>>> >
>>>> >
>>>> >
>>>> >
>>>>
>>>
>>>
>>
>>
>> 
> 
> 
> 
> 


From petexmldev@t... Thu Oct 11 08:32:12 2007
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4.63)
	(envelope-from <petexmldev@t...>)
	id


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent