W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2002

Re: contstraint on attribute combination?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 22 Jan 2002 09:18:33 +0000
Message-ID: <62151574652.20020122091833@jenitennison.com>
To: Sonja Löhr <sonjaloehr@onlinehome.de>
CC: xmlschema-dev@w3.org
Hi Sonja,

> Is there any way to require that some attributes must to occur together?
> I have an element "Get" the semantics of which and therefore the attributes
> required depend on the attribute ("source"). I created attributeGroups each
> with another fixed value for the required "source" attribute, but
> unfortunately one cannot embed attributeGroups in <choice> elements or some
> other representation with "or" semantics.
> I then created a complexType with each of the attributeGroups and a group
> like that
> <group name="SomeGetElement">
>     <choice>
>         <element name="Get" type="GetType1"/>
>         <element name="Get" type="GetType2"/>
>         <element name="Get" type="GetType3"/>
>     <choice>
> </group>
> but got an Error because of a "Unique Particle Attribution" violation. I
> don't want to specify "xsi:type" in the instance document, but is there any
> way out without breaking up my "Get" element into multiple elements?

In XML Schema, the only attribute that you can use to control the
content or the attributes of an element is the xsi:type attribute.

But rather than using different elements, you can always make a
general Get element, express as many of the rules about the Get
elements as you can in XML Schema, and then use another schema
language (possibly embedded in the xs:appinfo element) to articulate
other constraints. RELAX NG and Schematron are particularly good at
these kinds of rules.



Jeni Tennison
Received on Tuesday, 22 January 2002 04:18:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC