W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2002

Re: using xsd:choice + element value

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Tue, 28 May 2002 09:02:43 +0200 (CEST)
Message-ID: <33363.>
To: <xmlschema-dev@w3.org>

Eddie Robertsson said:
> Hi Matt,
>> The primary issue is that a schema needs to implement a 'choice' based
>> on a prior element 'value'.   The animal schema below illustrates the
>> point that the qualifier value of "dog | cat" cannot qualify the
>> choice elements (dogName | catName).  In other words the schema is
>> valid with
>>         <animalType>cat</animal>
>>         <dogName>Scooby</dogName>
>> which is not the intent and therefore is not properly communicated.
>> Is this simply not possible???
> Not with W3C XML Schema alone...

That's true unless (as it's often the case with W3C XML Schema) you accept
to change the structure of your instance documents to cope with the
limitation of the language.
In this case, using a xsi:type attribute to carry the type of animal:

<animal xsi:type="cat">

could do the trick if all the animal complex types can be derived from a
same generic animal type.
See you in San Diego.
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
Received on Tuesday, 28 May 2002 03:02:51 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:02 UTC