Re: trouble with content models

Michael Kay <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.