Re: using xsd:choice + element value

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