W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2001

XML Schema validation

From: <NJayaraman@tomax.com>
Date: Mon, 20 Aug 2001 12:09:33 -0400 (EDT)
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <OFEEF6C817.14A5019D-ON87256AAE.0057C597@tomax.com>
Hi,
     I am trying to validate a xml using the following code, but it doesn't
seem to validate. After getting the DOM tree I could always traverse the
tree. Please let me know if I am missing something here to validate this.
Thanks !!

org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
parser.setErrorHandler(new tomax.utils.ValidXMLErrorHandler());
try {
   parser.parse(new InputSource(new FileInputStream("product_codes.xml")));
//I expect Parser to throw error here
   newXsdTest.xmlDoc = newXsdTest.getXMLDOM();
   //....
   //...
}
// ....

Sample xml

<?xml version="1.0"?>
<xml_root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="simple_test.xsd">
     <dept>
          <dept_no_wrong_tag>30000</dept_no_wrong_tag>
          <description>Test Dept</description>
     </dept>
</xml_root>

Xml Schema

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="xml_root">
  <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="dept" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="dept_no" type="xsd:integer"/>
          <xsd:element name="description" type="xsd:string"/>
        </xsd:sequence>
         </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
   </xsd:complexType>
</xsd:element>
</xsd:schema>
Received on Wednesday, 22 August 2001 05:27:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:23 GMT