Re: ( A or B ) or both

Hi Frans,

>>(a, b?) | (b, a?)
> 
> 
> ...and expressed in XML Schema it looks like this? :
> 
> <xsd:complexType>
>     <xsd:choice>
>         <xsd:choice>
>             <xsd:element minOccurs="0" name="enable" type="state" />
>             <xsd:element  name="disable" type="state" />
>         </xsd:choice>
>         <xsd:choice>
>             <xsd:element name="enable" type="state" />
>             <xsd:element minOccurs="0" name="disable" type="state" />
>         </xsd:choice>
>     </xsd:choice>
> </xsd:complexType>
> 
> To me it looks ambiguous, since the second choice matches (A and B) just as 
> well as the first(but perhaps that doesn't matter).

No, you wrote (a? | b) | (a | b?) and this is not what I meant and also 
it is, as you noted, ambiguous and it will create problems, see 
http://www.w3.org/TR/xmlschema-1/#cos-nonambig

(a, b?) | (b, a?) is not ambiguous and in XML Schema notation will look 
like below.

<xs:choice>
     <xs:sequence>
         <xs:element name="enable" type="state"/>
         <xs:element name="disable" type="state" minOccurs="0"/> 

     </xs:sequence>
     <xs:sequence>
         <xs:element name="disable" type="state"/>
         <xs:element name="enable" type="state" minOccurs="0"/> 

     </xs:sequence>
</xs:choice>

>>>BTW, for another Schema of mine, I need to allow XHTML markup in some
>>>elements, in a way possible to validate. Should I simply reference the
>>>"block" element group in XHTML 1.0's XSD?
>>
>>I guess you can use a wildcard model here to specify any element from
>>the XHTML namespace. Setting processContents to strict will force the
>>validation to be applied on the XHTML content.
> 
> 
> However, one of intentions is to not allow any elements from the namespace, 
> such as html, body, or head, but only the content one usually finds /in/ the 
> body tag. From what I can tell, that means the complexType Block needs to be 
> used(rather than the block group which I said before), but that perhaps 
> doesn't work for some of the reasons you proposed an alternative approach?

Well, in your initial post you say XHTML markup and not only the 
elements that can be found inside body, thus my answer.
Your approach seems ok (reference the block group) if those elements are 
what you need.

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

Received on Monday, 8 November 2004 13:07:12 UTC