Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


xsi:type attribute in XML

From: "Jaikrishnan Pillai" <jaikrishnan.pillai@------.--->
To: <xmlschema-dev@--.--->
Date: 12/10/2004 11:56:00 AM
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/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.vordel.com/
file:///E:/TMobile/samplemessages/new/test/tony/test.xsd"
xsi:type="xsd:string">Error
</getCustomerID>


and the schema I have is

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.vordel.com/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:tns="http://www.vordel.com/">

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

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

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.

Thanks,
JK





Jaikrishnan R Pillai
Vordel - XML security and management
http://www.vordel.com
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



From noah_mendelsohn@u... Fri Dec 10 14:47:31 2004
Received: from bart.w3.org ([128.30.52.40])
	by frink.w3.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent