- From: youhaodeyi <youhaodeyi@gmail.com>
- Date: Wed, 26 Aug 2009 18:20:01 -0700 (PDT)
- To: xmlschema-dev@w3.org
I wish to create an XML document in which one of its elements must be
defined with one of two known attributes, but not both.
For example, I would like to define a "socketHandler" element as follows:
<xs:element name="socketHandler">
<xs:complexType>
<xs:attribute name="hostName" type="xs:string"/>
<xs:attribute name="hostAddress" type="xs:string"/>
<xs:attribute name="port" type="xs:int" use="required"/>
</xs:complexType>
</xs:element>
but I only want a user to be able to define either a hostName attribute
(e.g., hostName="<servername>") or a hostAddress (e.g.,
hostAddress="<IP_address>") attribute, but not both. It appears that the
<xs:choice> construct accomplishes this for elements. Is there a
functional
equivalent for attributes, or is there a better way to approach this?
--
View this message in context: http://www.nabble.com/XML-Schema-question%3A-A-%3Cxs%3Achoice%3E-equivalent-for-attributes--tp25164500p25164500.html
Sent from the w3.org - xmlschema-dev mailing list archive at Nabble.com.
Received on Friday, 28 August 2009 09:13:22 UTC