You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by "Asankha C. Perera" <as...@wso2.com> on 2006/05/15 13:30:32 UTC

Schema validation

I'm experiencing some issues running the Validation mediator test cases 
we introduced lately

Though the code runs on JDK 1.5, on JDK 1.4 versions I get errors such 
as org.xml.sax.SAXNotRecognizedException: 
http://xml.org/sax/features/validation. The following is the code 
fragment that I have right now.. and would like to how what is the 
'right'/'recommended' way to perform the Schema validation such that it 
will work on both JDK's and possibly other SAX parsers(?) and within 
JUnit tests..

thanks
asankha

    private static final String SCHEMA_LOCATION_NO_NS =
        
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
    private static final String SCHEMA_LOCATION_NS =
        "http://apache.org/xml/properties/schema/external-schemaLocation";
    private static final String FULL_CHECKING = 
"http://apache.org/xml/features/validation/schema-full-checking";
    private static final String SCHEMA_VALIDATION = 
"http://apache.org/xml/features/validation/schema";
    private static final String VALIDATION = 
"http://xml.org/sax/features/validation";

..................
.............
            SAXParserFactory spFactory = SAXParserFactory.newInstance();
            spFactory.setNamespaceAware(true);
            spFactory.setValidating(true);
            SAXParser parser = spFactory.newSAXParser();

            parser.setProperty(VALIDATION, Boolean.TRUE);
            parser.setProperty(SCHEMA_VALIDATION, Boolean.TRUE);
            parser.setProperty(FULL_CHECKING, Boolean.TRUE);
            parser.setProperty(SCHEMA_LOCATION_NS, nsLocations.toString());
            parser.setProperty(SCHEMA_LOCATION_NO_NS, getSchemaUrl());

            Validator handler = new Validator();
            parser.parse(baisFromSource, handler);



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org