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

 

Reply via email to