W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2004

Re: ( A or B ) or both

From: Frans Englich <frans.englich@telia.com>
Date: Mon, 8 Nov 2004 11:05:50 +0000
To: George Cristian Bina <george@oxygenxml.com>
Cc: xmlschema-dev@w3.org
Message-Id: <200411081105.50905.frans.englich@telia.com>

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

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 23:40:23 UTC