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>
     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
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"
          <description>Test Dept</description>

Xml Schema

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:52 UTC