W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2011

Re: XSD for 'at least one of'

From: Kevin Braun <kbraun@obj-sys.com>
Date: Thu, 06 Jan 2011 13:13:27 -0500
Message-ID: <4D260647.9020300@obj-sys.com>
To: George Francis <gfrancis1@gmail.com>
CC: xmlschema-dev@w3.org
Hi George,

On 1/6/2011 11:24 AM, George Francis wrote:
> Apologies if this is a PAQ, I can't find the answer.
> How do I specify in my XSD that an element must contain at least one 
> of it's child elements?
>  I've tried the following:
> <xs:complexTypename="options">
> <xs:choiceminOccurs="1"maxOccurs="unbounded">
> <xs:elementname='month'type="month"minOccurs="0"/>
> <xs:elementname='year'type="year"minOccurs="0"/>
> <xs:elementname='day'type="day"minOccurs="0"/>
> </xs:choice>
> </xs:complexType>
> but it still doesn't seem to care if 'options' is empty.

You made it legal to choose any of the choices zero times.  So, at least 
one time, you have to choose one of the elements and have it be there at 
least zero times.  You need to adjust the minOccurs on the elements 
inside the choice.  The minOccurs on the choice controls how many times 
you must make a choice.  The minOccurs on the things inside the choice 
controls how many times you must have that thing when you choose it.


Objective Systems, Inc.
Received on Thursday, 6 January 2011 18:35:08 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:18 UTC