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

"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 UTC