Orlando,
 
Are you sure that your version of Xerces-J provides good schema support? I had a similar problem when I was using an older version (1.1.3), but upgrading to 1.3.0 fixed the problem.
 
Ivan
-----Original Message-----
From: Orlando Ribeiro [mailto:[EMAIL PROTECTED]
Sent: Friday, May 04, 2001 5:34 PM
To: [EMAIL PROTECTED]
Subject: Problem with Xerces DOMParser Validation

Hi,

     

      First of all thanks for helping me trying to resolve the problem of the Xerces validation. I followed your instructions by trying to use the “setFeature(…)” and reading more about the features on the Xerces site http://xml.apache.org/xerces-j/features.html, but the results were not so good. I made the following modifications in my code:

 

      public org.w3c.dom.Document get_xerces_document (String Xml_FileName)

       {     

DOMParser domParser = new DOMParser();         

      

              try

              {

domParser.setFeature("http://xml.org/sax/features/validation",true);

 

domParser.setFeature("http://apache.org/xml/features/validation/schema",true);

 

domParser.setFeature("http://xml.org/sax/features/namespaces",true);

                    

              }catch (SAXNotRecognizedException e)

              {

                     System.err.println (e);

              } catch (SAXNotSupportedException e)

              {

                     System.err.println (e);

              }

 

              //Register Error Handler

              domParser.setErrorHandler (this);

 

try

              {     

domParser.parse( new InputSource( new FileInputStream( new File(xml_FileName) ) ) );

 

              }catch(IOException ex) {

                     ex.printStackTrace();

              }catch(org.xml.sax.SAXException ex) {

                     ex.printStackTrace();

              }

             

              return domParser.getDocument();

       }

 

     

      The returned messages by the “Error Handler” were:

 

Error:  org.xml.sax.SAXParseException: Element type "orlando" must be declared.

Error:  org.xml.sax.SAXParseException: Element type "name" must be declared.

Error:  org.xml.sax.SAXParseException: Element type "surname" must be declared.

Error:  org.xml.sax.SAXParseException: Element type "age" must be declared.

 

The documents used for these were (one XML and the other is a Schema):

 

orlando.xsd:

 

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">

       <xsd:element name="orlando" type="Dados"/>

       <xsd:complexType name="Dados">

             <xsd:sequence>

                    <xsd:element name="name" type="xsd:string"/>

                    <xsd:element name=" surname" type="xsd:string"/>

                    <xsd:element name="age" type="xsd:integer"/>

             </xsd:sequence>

       </xsd:complexType>

</xsd:schema>

 

myExample.xml:

 

<?xml version="1.0" encoding="UTF-8"?>

<orlando xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\TEMP\orlando.xsd">

       <name>Orlando</name>

       <surname>Ribeiro</surname>

       <age>24</age>

</orlando>

 

 

I don’t understand the meaning of these messages since there is no problem with the used document structure (the document is well-formed).

 

 

Am I doing something wrong or am I missing something? I can proceed with the validation using a schema file, right?

One more time I ask for your help. Could anybody tell me what should I do to make this work?

 

 

Thanks in advance,

Orlando Ribeiro

 

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please immediately delete it and all
copies of it from your system, destroy any hard copies of it and notify the
sender. You must not, directly or indirectly, use, disclose, distribute,
print, or copy any part of this message if you are not the intended
recipient. CREDIT SUISSE GROUP and each of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks. Any
views expressed in this message are those of the individual sender, except
where the message states otherwise and the sender is authorised to state
them to be the views of any such entity.
Unless otherwise stated, any pricing information given in this message is
indicative only, is subject to change and does not constitute an offer to
deal at any price quoted.
Any reference to the terms of executed transactions should be treated as
preliminary only and subject to our formal written confirmation.



Reply via email to