Hi Jasbir,
Seems like you might not have set the feature
http://apache.org/xml/features/validation/schema. the SAX validation
feature just enables DTD validation; there's no DTD in your document so
Xerces DTD routines are complaining.
BTW: questions like this are better posted to the xerces-j-user list.
Thanks!
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone: 905-413-3519, T/L 969-3519
E-mail: [EMAIL PROTECTED]
|---------+---------------------------->
| | Jasbir X Matharu |
| | Sent by: � |
| | |
| | |
| | 12/17/2002 06:28 |
| | AM |
| | Please respond to|
| | xerces-j-dev |
| | |
|---------+---------------------------->
>---------------------------------------------------------------------------------------------------------------------------------------------|
|
|
| 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
==================================================
HFC Bank Disclaimer
The information in this Email belongs to HFC Bank plc. It is intended for
the use of the individual or entity to which it is addressed and may
contain information that is privileged, confidential and exempt from
disclosure under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution or the
taking of any action in reliance on the contents of this Email is
prohibited. If you have received this Email in error, please notify us
immediately by telephone on 01344 890000 and delete the Email from your
system and destroy all copies which you have made of the same. Thank you.
HFC Bank plc Company Registration Number - 1117305 England
Registered Office: North Street, Winkfield Berkshire SL4 4TD.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]