Problem with XML Schema resource location in default handler

Hi,
I have been using XML schema for validating XML documents in one of our applications and i've been using the xercer java parser 2.0.1

It seems to be doing its job well if i specify the following in the instance document..

<TESTDATA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="c:\jakarta-tomcat-4.0.3\webapps\struts-upload\testdata.xsd">

...


</TESTDATA>



But i've been trying to specifiy the property for locating the schema in a class that implements the default handler,

<TESTDATA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

...

</TESTDATA>

code snippet:

	XMLReader xr = XMLReaderFactory.createXMLReader();
	
	//set the following properties
            xr.setProperty(EXTERNAL_SCHEMA_NONAMESPACE_LOCATION_PROPERTY_ID,"c:\jakarta-tomcat-4.0.3\webapps\struts-upload\testdata.xsd");


	//set the following features
            xr.setFeature(NAMESPACES_FEATURE_ID, true);            
            xr.setFeature(NAMESPACE_PREFIXES_FEATURE_ID, true);           
            xr.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); 
            xr.setFeature(VALIDATION_FEATURE_ID, true);
            xr.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);                  
            xr.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, true);
	xr.parse( new InputSource(fileInputStream) ); //pass the XML file input stream

The handler just parses the XML file.. but the rules are not validated. But the validations are done if i specify the schema location in the instance document.

Could any one please let me know if i'm missing anything..

- Kalyan

Received on Wednesday, 26 June 2002 03:54:31 UTC