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.192.127.127.15.1022569363.squirrel@poweredge.paris.dyomedea.com>
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">
 .../...
</animal>

could do the trick if all the animal complex types can be derived from a
same generic animal type.
Eric
-- 
See you in San Diego.
                               http://conferences.oreillynet.com/os2002/
------------------------------------------------------------------------
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.3.1 : Wednesday, 7 January 2015 14:55:56 UTC