Hi Jasbir, Following is the right XML file::
<?xml version="1.0" ?> <Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="jasbir.xsd"> <Transaction xsi:type="_Transaction_Login"> <user_id>test</user_id> <password>xxx</password> </Transaction> </Request> Also, as u dont have DTD, so set the DTD feature to false , and true for Schema xr.setFeature( "http://xml.org/sax/features/validation",false); xr.setFeature( "http://xml.org/sax/features/namespaces",true); xr.setFeature( "http://apache.org/xml/features/validation/schema",true); Regds, Anoop Singh -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tue 12/17/2002 4:58 PM To: [EMAIL PROTECTED] Cc: Subject: Schema validation problem with xsi:type I have problems when attempting to use the xsi:type parameter in a schema with Xerces. Here is a sample schema. <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="_Transaction" abstract="true"> <xs:sequence> <xs:element name="user_id"/> </xs:sequence> </xs:complexType> <xs:complexType name="_Transaction_Login"> <xs:complexContent> <xs:extension base="_Transaction"> <xs:sequence> <xs:element name="password"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="_Transaction_Submit"> <xs:complexContent> <xs:extension base="_Transaction"> <xs:sequence> <xs:element name="application_number"> </xs:element> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name="Request"> <xs:complexType name=""> <xs:sequence> <xs:element name="Transaction" type="_Transaction"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> If I validate it with the following XML in XML Spy then it works fine. <?xml version="1.0" encoding="UTF-8"?> <Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Transaction xsi:type="_Transaction_Login"> <user_id>test</user_id> <password>xxx</password> </Transaction> </Request> Under Xerces it reports the following error Parsing error: Document root element "Request", must match DOCTYPE root "null". Parsing error: Document is invalid: no grammar found. The test code I'm using is this._parser = new SAXParser(); this._parser.setFeature ("http://xml.org/sax/features/validation",true); this._parser.setProperty ("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", "/test/test3.xsd"); this._parser.setErrorHandler(this.new B2BSaxHandler()); String xml = "<Request xmlns:xsi =\"http://www.w3.org/2001/XMLSchema-instance\">"+ "<Transaction xsi:type=\"_Transaction_Login\">"+ "<user_id>test</user_id>"+ "<password>xxx</password>"+ "</Transaction>"+ "</Request>"; System.out.println(xml); StringReader data = new StringReader(xml); _parser.parse(new org.xml.sax.InputSource(data)); _parser.reset(); Any help is appreciated! Jasbir
<<winmail.dat>>
**************************Disclaimer************************************************** Information contained in this E-MAIL being proprietary to Wipro Limited is 'privileged' and 'confidential' and intended for use only by the individual or entity to which it is addressed. You are notified that any use, copying or dissemination of the information contained in the E-MAIL in any manner whatsoever is strictly prohibited. ****************************************************************************************
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
