<xs:choice> equivalent for attributes

4 views
Skip to first unread message

sarabjit kaur

unread,
May 16, 2008, 7:10:20 AM5/16/08
to XML Schema
Hi,

I wish to create an XML document in which one of its elements must be
defined with one of two known attributes.

For example, I would like to define a "Parent" element as follows:

<xs:element name="Parent">

<xs:complexType>

<xs:attribute name="Name" type="xs:string"/>

<xs:attribute name="ID" type="xs:string"/>

</xs:complexType>

</xs:element>

but I only want a user to be able to define atleast one among ID and
name attribute
(i.e, I can have name and ID both or only ID or only name but none is
not possible).
It appears that the <xs:choice> construct accomplishes this for
elements. Is there a functional equivalent for attribute or another
way this can be achieved in XSD.

Regards
Sarabjit

Reply all
Reply to author
Forward
0 new messages