- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 5 Mar 2003 16:14:49 +0000
- 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:choice> <xs:sequence> <xs:element name="Sub1" type="xsd:string"/> <xs:element name="Sub2" type="xsd:string"/> <xs:element name="Sub3" type="xsd:string"/> </xs:sequence> <xs:sequence> <xs:element name="Sub4" type="xsd:string"/> <xs:element name="Sub5" type="xsd:string"/> </xs:sequence> </xs:choice> </xs:complexType> 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. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Wednesday, 5 March 2003 11:15:23 UTC