W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2009

XML Schema question: A <xs:choice> equivalent for attributes?

From: youhaodeyi <youhaodeyi@gmail.com>
Date: Wed, 26 Aug 2009 18:20:01 -0700 (PDT)
Message-ID: <25164500.post@talk.nabble.com>
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:attribute name="hostName" type="xs:string"/>

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

         <xs:attribute name="port" type="xs:int" use="required"/>



 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
 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

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