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

Re: only one of the element is req but not both...

From: Eddie Robertsson <eddie@allette.com.au>
Date: Sat, 01 Dec 2001 14:03:34 +1100
Message-ID: <3C084886.AA5AE646@allette.com.au>
To: "Henry S. Thompson" <ht@cogsci.ed.ac.uk>
CC: "Hanumaiahgari, Srinivas" <Srinivas.Hanumaiahgari@dva.gov.au>, "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
"Henry S. Thompson" wrote:

> Eddie Robertsson <eddie@allette.com.au> writes:
>
> > > 1.I got 'dateDispatched' and 'dateDelivered' in my schema and i want to
> > > check wherein one of them is required but not both and the other should be
> > > empty.
> >
> > You can't do this with W3C XML Schema alone . . .
>
> Um, depends on exactly what was meant, but
>
> <xs:choice>
>  <xs:element name='dateDispatched' . . ./>
>  <xs:element name='dateDelivered' . . ./>
> </xs:choice>
>
> should do the job.

Yes, but I got the impression that both elements should always be present but only
one of them should contain a value and the other should be empty. For example
these to instances would be valid:

<test>
   <dateDispatched>2001-11-30</dateDispatched>
   <dateDelivered></dateDelivered>
</test>

<test>
   <dateDispatched></dateDispatched>
   <dateDelivered>2001-11-30</dateDelivered>
</test>

But the following two would be invalid:

<test>
   <dateDispatched>2001-11-30</dateDispatched>
   <dateDelivered>2001-11-30</dateDelivered>
</test>

<test>
   <dateDispatched></dateDispatched>
   <dateDelivered></dateDelivered>
</test>


Cheers,
/Eddie
Received on Friday, 30 November 2001 21:56:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT