Re: Variation depending on attribute value

Hi Ken,

On Mon, 2003-08-04 at 14:45, G. Ken Holman wrote:
> At 2003-08-04 13:17 +0200, Camilla Brenchley wrote:
> >Given the below schema, is it possible to specify that if the attribute
> >"Type" equals "Double" then the element "WithDoubleBed" is required, i.e.
> >minOccurs="1", and if it equals "DoubleOneChild" then the element "ChildAge"
> >is required?
> 
> This is a co-occurrence constraint and I believe it cannot be supported in 
> W3C Schema (though it can be supported using RELAX-NG).  I'd like to be 
> proven wrong, though, as it a common requirement and applications would be 
> unencumbered with certain validation checking if it were available.

That would be possible if you accepted to change the "Type" attribute by
a "xsi:type" attribute, in which case if you've defined complex types
named "Single", "Double" and "DoubleOneChild" derived from the datatype
assigned to your element you'd assign one of these types to your
element.

Hope this helps.

Eric
-- 
Read me on XMLhack.
                                      http://xmlhack.com/author.php?id=8
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------

Received on Monday, 4 August 2003 23:29:42 UTC