W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: [RE: Conditional typing] xsi:type not checked against schema

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Mon, 11 Feb 2002 14:34:47 +0100
Message-ID: <3C67C877.3080002@dyomedea.com>
To: Piccand Régis <regis.piccand@imtf.ch>
Cc: " 'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Piccand Régis wrote:

> Hello again,
> 
> (Eric, I have upgraded to XML Spy 4.3 and it works nearly fine now...)


Great!


> 
> When using xsi:type in an instance document, the validation checks that the
> value of the tag is valid, but the type specified is not checked against the
> schema.
> 
> For instance, my "element" is of type "valueType" which is a union of
> base64Binary and string.
> 
> In an instance document, any xsi:type is accepted.
> 
> schema :
> 	<xs:element name="root">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element name="element"
> type="valueType"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	<xs:simpleType name="valueType">
> 		<xs:union memberTypes="xs:base64Binary xs:string"/>
> 	</xs:simpleType>
> 
> 
> valid instance :
> 
> 	<element xsi:type="xs:int">1</element> 
> 	<element xsi:type="xs:boolean">1</element> 
> 	<element xsi:type="xs:string">hello world</element> 
> 
> - As far as I understand, only xs:string and xs:base64Binary should be
> accepted. Is that true ?


Almost. As defined here, "valueType" can also be used.


> - Is there a way to make the xsi:type attribute compulsory ?


On a complex type, the "abstract" attribute is a way to make it unusable 
directly which is equivalent to making xsi:type compulsory, but this 
feature doesn't exist for a simple type.

To do so, I think that you will need to define simple content complex 
types which you will use instead of xs:string, xs:base64Binary and 
valueType and define the new "valueType" as abstract.

Hope this helps.

Eric


> Thanks for your support
> 
> Régis


-- 
Rendez-vous a Paris pour mes formations XML/XSLT.
                                           http://dyomedea.com/formation/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
------------------------------------------------------------------------
Received on Monday, 11 February 2002 08:35:21 GMT

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