Gehirnloser Zombie wrote:
Short question: Is it possible to express with XML-Schema that for an
element some attributes may apear only disjunctivly (i.e. an element
<E> can either carry the attribute "a1" OR "a2", but never both of
them)?
I know one way to do that, by defining a base type and deriving two
types from and then use xsi:type on the instance data:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test20040112Xs d.xml">
<element xsi:type="elTyp e1" a1="value" />
<element xsi:type="elTyp e2" a2="value" />
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType >
<xs:sequence>
<xs:element ref="element" maxOccurs="unbo unded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="element" type="elType" />
<xs:complexTy pe name="elType" />
<xs:complexTy pe name="elType1">
<xs:complexCont ent>
<xs:extension base="elType">
<xs:attribute name="a1" type="xs:string " />
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
<xs:complexTy pe name="elType2">
<xs:complexCont ent>
<xs:extension base="elType">
<xs:attribute name="a2" type="xs:string " />
</xs:extension>
</xs:complexConte nt>
</xs:complexType>
</xs:schema>
I don't think you can do it without xsi:type.
--
Martin Honnen
http://JavaScript.FAQTs.com/