Re: xsd:choice between simpleContent and an element

The only way I can see you doing this is:

option 1) declaring "Distribution" as an ANY data type (but you lose
enforcement of data types)

or option 2) you need to define two elements and keep the choice (but the
two elements can't both be named the same thing).

But I suspect neither of these is exactly what you want.

You may also try something like using "xsi:type" in the instance, but I have
no experience with that.

Cheers,
Paul

W. Paul Kiel
HR-XML Consortium

----- Original Message ----- 
From: "Jeremy Vander Kam (ARC)" <Jeremy.C.VanderKam@nasa.gov>
To: <xmlschema-dev@w3.org>
Sent: Monday, December 01, 2003 1:27 PM
Subject: xsd:choice between simpleContent and an element


>
> Hi all,
>
> I would like to do something like this:
>
> <xsd:complexType name="MyType">
>   <xsd:choice>
>    <xsd:element name="Distribution" type="DistType"/>
>    <xsd:simpleContent>
>      <xsd:extension base="xsd:double">
>        <xsd:attribute name="type" use="required">
>            <xsd:simpleType>
>              <xsd:restriction base="xsd:string">
>                <xsd:enumeration value="double"/>
>              </xsd:restriction>
>            </xsd:simpleType>
>          </xsd:attribute>
>      </xsd:extension>
>    </xsd:simpleContent>
>   </xsd:choice>
> </xsd:complexType>
>
> So I have the option of defining an element by either a set of attributes
> and simple content OR by a child element.... Is this possible? If so, how?
> I would like to be able to specify something like:
>
> <xsd:element name="Variable" type="MyType/>
>
>   such that the resulting XML could be either:
>
> <Variable>42.1</Variable>
>
> or
>
> <Variable>
>    <Distribution/>
> </Variable>
>
> But NOT mixed content such as:
>
> <Variable>
>    42.1<Distribution/>
> </Variable>
>
> So I guess the "gotcha" is that I want to control the type of the content
> when it is simpleContent - making it xsd:double in this example.
>
> Thanks!
>
>
> ----------
> Jeremy Vander Kam
> Aerospace Engineer
> Systems Analysis Branch
> NASA Ames Research Center
> Jeremy.C.VanderKam@nasa.gov
> 513 871 7425
>
>
>

Received on Friday, 5 December 2003 14:06:15 UTC