Re: Fwd: [Moderator Action] Question about GROUP and CHOICE combined

The XML Schema does not allow ambiguous content, so you cannot say that 
some element contains either X followed by something or X followed by 
something else.
You can read more about this here:
http://www.w3.org/TR/xmlschema-1/#cos-nonambig
http://www.w3.org/TR/xmlschema-1/#non-ambig

The general solution to this problem is to factor the content model, for 
instance instead of

(x, y) | (x, z)

you can write

x, (y | z)

This may become really complicated if your content model is more complex 
so if the choice for the schema language is in your hands then you may 
consider Relax NG as it handles such ambiguous content.

Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Chris Lilley wrote:
> This is a forwarded message
> From: ?? <mcha226@gmail.com>
> To: "public-schemata-users@w3.org" <public-schemata-users@w3.org>
> Date: Thursday, December 15, 2005, 10:48:59 PM
> Subject: [Moderator Action] Question about GROUP and CHOICE combined
> 
> ===8<==============Original message text===============
> Apologies if this question is too easy or if I have not read the schema
> documentation enough.
> 
> My schema is like this: There will be a choice between one of the two groups
> a and b.
> 
> ...
>         <xs:choice>
>                 <xs:group ref="a"/>
>                 <xs:group ref="b"/>
>         </xs:choice>
> ...
> 
> however if I have the following group declaration it will not pass. The
> error message will say that "X" cannot appear in both groups.
> 
>   ...
>         <xs:group name="a">
>                 <xs:sequence>
>                         <xs:element ref="X"/>
>                         <xs:element ref="Y"/>
>                 </xs:sequence>
>         </xs:group>
>         <xs:group name="b">
>                 <xs:sequence>
>                         <xs:element ref="X"/>
>                         <xs:element ref="Z"/>
>                 </xs:sequence>
>         </xs:group>
>   ...
>   ...
> 
> The strange thing is that if I have the following combination it will
> not work:
> XY XY
> XY XX
> 
> However the following will work:
> XY YX
> XX YX
> XY YY
> 
> This means that it will only fail if the first element of both group is the
> same. Anything else will pass. This seemed really strange
> to a newbie like me. Is there anyway around it? By the way I am using the
> validator from here:
> http://tools.decisionsoft.com/schemaValidate.html
>  Cheers
> Mark
> 
> ===8<===========End of original message text===========
> 
> Non-member posting
> 

Received on Friday, 16 December 2005 07:36:32 UTC