W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2004

xsi:type attribute in XML

From: Jaikrishnan Pillai <jaikrishnan.pillai@vordel.com>
Date: Fri, 10 Dec 2004 11:56:22 -0000
To: <xmlschema-dev@w3.org>
Message-ID: <DHEDINNJHMODMNHMIKKGOECNCNAA.jaikrishnan.pillai@vordel.com>

Hi ,
I am trying to do a schema validation using Xerces(version 2.2.1).The xml I
have is

<getCustomerID xmlns="http://www.vordel.com/"

and the schema I have is

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.vordel.com/"

<xsd:element name="getCustomerID">
                     <xsd:union memberTypes="xsd:string"/>
                   <xsd:enumeration value="JK" />
                   <xsd:enumeration value="DAVE" />

<xsd:simpleType name="derived_string">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="JK" />
     <xsd:enumeration value="DAVE" />

Now what i want my schema to achieve is to restrict the value to either
"DAVE" or "JK".Also note the xsi:type attrbute in the schema.
Even if the value is different I am still able to validate the schema. Is
this the expected beahaviour?

Now if I take away the xsi:type="xsd:string" from the xml.Then it will try
to validate the content and gives me the correct exception.
Now I need to have  type attribute as the Web service rquires it.So I want
to build up a schema for the same.

I changed the schema to use <xsd:union memberTypes="tns:derived_string"/>
then it gives me a error
org.xml.sax.SAXParseException: cvc-elt.4.3: Type 'xsd:string' is not validly
derived from the type definition of element 'getCustomerID'.

Can someone help me out.I want to know how does schema validation differ
when there is xsi:type attribute in xml itself.


Jaikrishnan R Pillai
Vordel - XML security and management
Tel:      +353-1-603 1706
Fax:     +353-1- 603 1701

- Vordel and Software AG to deliver secure integration solutions
- Vordel CTO writes the book on Web Services security
Received on Friday, 10 December 2004 12:37:45 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:07 UTC