W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2001

Re: [Moderator Action] Choice group element

From: Jeff Rafter <jeffrafter@definedweb.com>
Date: Mon, 5 Mar 2001 08:59:13 -0800
Message-ID: <036d01c0a595$9b9e8020$f181fea9@lazarus>
To: "Henry S. Thompson" <ht@cogsci.ed.ac.uk>, <seema_mehta@nzi.co.nz>
Cc: <xmlschema-dev@w3.org>
 > Can you use choice to select elements of the same name but different
type.
 > In other words is the following legal:
 >
 > <choice>
 >     <element    name="a"    type="x"/>
 >     <element    name="a"    type="y"/>
 >     <element    name="a"    type="z"/>
 > </choice>

Henry is definitely right-- a good workaround (which may not be useful in
your case) is to use the extension model built into schemas.  Build a
complexType "w" which may or may not define content-- and then use that as
the base for extending "x", "y", and "z".  Then your choice would look
something like:

 <choice>
     <element    name="a"    type="w"/>
 </choice>

And within your instance you could specify the actual type used by
indicating xsi:type="y".  Other than that there may be a couple of other
indirect approaches using substitution (?) but they aren't popping to mind
so quickly.

Good Luck,
Jeff Rafter
Received on Monday, 5 March 2001 11:59:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:20 GMT