1. You meant

xr.setProperty(...,"c:
\\jakarta-tomcat-4.0.3\\webapps\\struts-upload\\testdata.xsd");

right? (double back-slash.)

2. Try not to turn on "dynamic validation" feature. This feature doesn't
always work with schema validation.

Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
[EMAIL PROTECTED]



                                                                                
                                    
                    <[EMAIL PROTECTED]                                          
                                  
                    rline.com>                 To:     <[EMAIL PROTECTED]>      
                         
                                               cc:                              
                                    
                    06/25/2002 10:18 PM        Subject:     Problem with XML 
Schema resource location in default    
                    Please respond to           handler                         
                                    
                    xerces-j-user                                               
                                    
                                                                                
                                    
                                                                                
                                    



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:


String EXTERNAL_SCHEMA_NONAMESPACE_LOCATION_PROPERTY_ID = "
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
";


        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 event handler class just parses the XML file.. and the rules specified
in the schema are not validated.


I also tried with "
http://apache.org/xml/properties/schema/external-schemaLocation";; and
provided a URI before the XSD file while setting the property, but no luck


Could any one please let me know if i'm missing anything..
Would appreciate a ton...


- Kalyan







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

Reply via email to