Hi
I am using xerces 1.4.4, JDK 1.3.1
Following code doesn't work as expected. Looks like it never validates,
even if I introduce some errors in the xml it doesn't complain
public static Document validate(InputSource source,String schema)
throws SAXException{
try{
System.out.println("In XmlUtils.validate(): " + schema);
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/validation",true);
parser.setFeature("http://xml.org/sax/features/namespaces",
true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setFeature("http://apache.org/xml/features/validation/dynamic",
true);
parser.setFeature("http://apache.org/xml/features/validation/schema-full-che
cking", true);
parser.setProperty("http://apache.org/xml/properties/schema/external-schemaL
ocation",schema);
parser.parse(source);
Document doc = parser.getDocument();
Node root = doc.getDocumentElement();
System.out.println("Document name is:" +
root.getNodeName());
return doc;
}
catch (Exception se){
System.out.println("Error message: " + se.getMessage());
se.printStackTrace();
throw new SAXException(se.getMessage());
}
Calling the above function like below
Document xmlDocument = XmlUtils.validate(new InputSource(in),
"C:\\test.xsd");
It doesn't through any exception even if I change the xml not to confer with
schema. It prints the
root.getNodeName() and returns the document properly. If schema file
test.xsd not exists it complains
Any help is appreciated
Thanks
-Chandra Talluri
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]