- From: Michael Kay <mike@saxonica.com>
- Date: Wed, 15 Dec 2010 09:23:26 +0000
- To: Andy Davidson <andy_davidson@apple.com>
- CC: xmlschema-dev@w3.org
- Message-ID: <4D08890E.9030205@saxonica.com>
On 15/12/2010 03:43, Andy Davidson wrote: > 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? You could do that using xs:all. However, your code suggests that you are actually trying to define (ab | cd | abcd) which can't be tackled that way, though it can be done easily enough as (((ab)? cd) | cd). When I see content models like this, I'm always inclined to ask why? I can see an argument for a very strict order of children, or for a very liberal order, I find it harder to see how a requirement arises for something in between. Michael Kay Saxonica > > 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. > > <groupname="POSTransactionLineItemDiscountByAmount"id="POSTransactionLineItemDiscountByAmount"> > <sequence> > <elementname="discountAmount"type="decimal"minOccurs="0"/> > <elementname="discountAmountReasonCode"type="string"minOccurs="0"/> > </sequence> > </group> > > <groupname="POSTransactionLineItemDiscountByPercent"> > <sequence> > <elementname="discountPercentage"type="decimal"minOccurs="0"/> > <elementname="discountPercentageReasonCode"type="string"minOccurs="0"/> > </sequence> > </group> > > <groupname="POSTransactionLineItemDiscountByAmountAndPercent"> > <sequence> > <elementname="discountAmount"type="decimal"minOccurs="0"/> > <elementname="discountAmountReasonCode"type="string"minOccurs="0"/> > <elementname="discountPercentage"type="decimal"minOccurs="0"/> > <elementname="discountPercentageReasonCode"type="string"minOccurs="0"/> > </sequence> > </group> > > <complexTypename="POSTransactionLineItemDiscount"> > <sequence> > <choice> > <groupref="pos:POSTransactionLineItemDiscountByAmountAndPercent"/> > <groupref="pos:POSTransactionLineItemDiscountByAmount"/> > <groupref="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 09:23:56 UTC