W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2003

Re: Variation depending on attribute value

From: Eric van der Vlist <vdv@dyomedea.com>
Date: 05 Aug 2003 05:29:35 +0200
To: xmlschema-dev@w3.org
Message-Id: <1060054175.3659.27.camel@ibook>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:39 GMT