- From: <NJayaraman@tomax.com>
- Date: Mon, 20 Aug 2001 12:09:33 -0400 (EDT)
- To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
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 UTC