Re: contstraint on attribute combination?

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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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