Re: ( A or B ) or both

On Monday 08 November 2004 10:20, George Cristian Bina wrote:
> Hi Frans,

Hello George,

Thanks for your reply.

>
> > For an XML Schema complexType, I would like to specify such that it must
> > contain either of the elements A or B, but it /may/ also contain them
> > both(but at a minimum must A or B be there). In other words, I'm talking
> > about a logical OR.
> >
> > How is this done? If i put minOccurs="0" on A and B, that allows none of
> > them to be there. Somehow must the relation between the two be expressed.
>
> (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).

>
> > 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?


Cheers,

		Frans

Received on Monday, 8 November 2004 10:58:53 UTC