Hi all,

I'm trying to validate an XML document with a Schema, using SAXParser and 
whatever I do, the document validates,
even when the document and schema don't match, i.e. I use a totally irrelevant 
schema. Is what I'm doing correct? or even possible?
I can't unfortunately go down the DOM path, as we have memory limits, and some 
of the files we need to validate will be rather large.

This is the code I'm using, have I done soemthing outrageously wrong here ?

---------------------------------------------------------
String urlStr = /** the string url of the document I wish to validate **/
String MY_XSD = "http://localhost:8282/my.xsd";;
String SCHEMA_LOCATION = 
"http://apache.org/xml/properties/schema/external-schemaLocation";;

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);        
factory.setNamespaceAware(true);
                            
SAXParser saxParser = factory.newSAXParser();
XMLReader reader = saxParser.getXMLReader();
                            
reader.setFeature("http://xml.org/sax/features/validation";, true);
reader.setFeature("http://apache.org/xml/features/validation/schema";, true);
reader.setProperty(SCHEMA_LOCATION, MY_XSD );                           

saxParser.parse(urlStr, new DefaultHandler());
---------------------------------------------------------------------

Regards

Simon



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to