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

RE: Variation depending on attribute value

From: Camilla Brenchley <cbrenchley@transhotel.com>
Date: Wed, 6 Aug 2003 18:52:11 +0200
To: "Xmlschema-Dev" <xmlschema-dev@w3.org>
Message-ID: <JKEGLBMFMFBPIFCOOHHJMEGCCAAA.cbrenchley@transhotel.com>

Hi Eric,

Thanks a lot for your help, and sorry for the late reply.

I'm afraid I'm not a very advanced schema programmer... You wouldn't by any
chance happen to have an example handy? It would be a great help if I could
see how the xsi:type attribute would be implemented.

Thanks again,
Camilla

-----Mensaje original-----
De: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org]En
nombre de Eric van der Vlist
Enviado el: martes, 05 de agosto de 2003 5:30
Para: xmlschema-dev@w3.org
Asunto: 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 Wednesday, 6 August 2003 12:55:07 GMT

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