Re: trouble with content models

Hi Pete

thanks your approach works. I would never have thought of using ((a & b?) | b)

Andy


On Dec 15, 2010, at 1:19 AM, Pete Cordell wrote:

> Hi Andy,
> 
> Would something like the following work?
> 
> <group name="POSTransactionLineItemDiscountByAmount" id="POSTransactionLineItemDiscountByAmount">
> <sequence>
>    <element name="discountAmount" type="decimal" minOccurs="0"/>
>    <element name="discountAmountReasonCode" type="string" minOccurs="0"/>
> </sequence>
> </group>
> 
> <group name="POSTransactionLineItemDiscountByPercent">
> <sequence>
> <element name="discountPercentage" type="decimal" minOccurs="0"/>
>       <element name="discountPercentageReasonCode" type="string" minOccurs="0"/>
> </sequence>
> </group>
> 
> <complexType name="POSTransactionLineItemDiscount">
> <sequence>
>      <choice>
>       <sequence>
>      <group ref="pos:POSTransactionLineItemDiscountByAmount" />
>      <group ref="pos:POSTransactionLineItemDiscountByPercent" minOccurs="0" />
>       </sequence>
>      <group ref="pos:POSTransactionLineItemDiscountByPercent" />
>      </choice>
> </sequence>
> </complexType>
> 
> i.e. ((a & b?) | b)
> 
> Also, do you mean your group members such as discountAmount to have minOccurs="0"?  I think this defeats your wanting to have your & condition as POSTransactionLineItemDiscountByAmount & POSTransactionLineItemDiscountByPercent may be present but POSTransactionLineItemDiscountByPercent could be empty.
> 
> HTH,
> 
> Pete Cordell
> Codalogic Ltd
> Interface XML to C++ the easy way using C++ XML
> data binding to convert XSD schemas to C++ classes.
> Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
> for more info
> ----- Original Message ----- From: "Andy Davidson" <andy_davidson@apple.com>
> To: <xmlschema-dev@w3.org>
> Sent: Wednesday, December 15, 2010 3:43 AM
> Subject: trouble with content models
> 
> 
> Hi
> 
> its been a while since I worked with XML Schema. I am not sure I am posting to the correct group. I want to define a content model (a | b | (a &b))
> 
> Any idea how I can do this?
> 
> I have tried various version of the following I keep getting the following validation error from Eclipse on my POSTransactionLineItemDiscount type
> 
> cos-nonambig: discountAmount and discountAmount (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.
> 
> <group name="POSTransactionLineItemDiscountByAmount" id="POSTransactionLineItemDiscountByAmount">
> <sequence>
>    <element name="discountAmount" type="decimal" minOccurs="0"/>
>    <element name="discountAmountReasonCode" type="string" minOccurs="0"/>
> </sequence>
> </group>
> 
> <group name="POSTransactionLineItemDiscountByPercent">
> <sequence>
> <element name="discountPercentage" type="decimal" minOccurs="0"/>
>       <element name="discountPercentageReasonCode" type="string" minOccurs="0"/>
> </sequence>
> </group>
> 
> <group name="POSTransactionLineItemDiscountByAmountAndPercent">
> <sequence>
> <element name="discountAmount" type="decimal" minOccurs="0"/>
>       <element name="discountAmountReasonCode" type="string" minOccurs="0"/>
> <element name="discountPercentage" type="decimal" minOccurs="0"/>
>       <element name="discountPercentageReasonCode" type="string" minOccurs="0"/>
> </sequence>
> </group>
> 
> <complexType name="POSTransactionLineItemDiscount">
> <sequence>
>      <choice>
>   <group ref="pos:POSTransactionLineItemDiscountByAmountAndPercent" />
>      <group ref="pos:POSTransactionLineItemDiscountByAmount" />
>      <group ref="pos:POSTransactionLineItemDiscountByPercent" />
>      </choice>
> </sequence>
> </complexType>
> 
> I guess I could define a complex base type, and have three extensions to cover the 3 possible content valid content models. How ever this would require me to rework some legacy java applications
> 
> thanks
> 
> Andy
> 
> 
> 
> 

Received on Wednesday, 15 December 2010 19:37:59 UTC