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

Re: Generic Question

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 5 Mar 2003 16:14:49 +0000
Message-ID: <86508978802.20030305161449@jenitennison.com>
To: Shirish Kulkarni <shirish_kul@yahoo.com>
CC: xmlschema-dev@w3.org

Hi Shirish,

> Another dimension to the problem is when I would not like to have
> the Type1 or Type2 exposed to the instance document ( but a common
> type "TopType" is fine ) and still able to switch the validation to
> the required type internally.

I'm afraid that you can't do that. If you want the element to be of a
particular type then you have to use the xsi:type attribute to
indicate that type. If you label the element has being of the type
"TopType" then it will be taken as being of the type "TopType", not of
the type "Type1" or "Type2".

Of course you can do:

<xs:complexType name="TopType">
      <xs:element name="Sub1" type="xsd:string"/>
      <xs:element name="Sub2" type="xsd:string"/>
      <xs:element name="Sub3" type="xsd:string"/>
      <xs:element name="Sub4" type="xsd:string"/>
      <xs:element name="Sub5" type="xsd:string"/>

if you only want to say that the <Node> element has one of the two
content models, but the <Node> element itself will still be of the
type TopType.



Jeni Tennison
Received on Wednesday, 5 March 2003 11:15:23 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:09 UTC