Hi All,
I am reading xml,schema from a jar file, and trying the validate the xml with the schema, If I give complete path in the xsi:noNamespaceSchemaLocation, it works fine, but if I give the relative path, it doesn't. I tried by setting the setSystemId as well, but in vain.
Is there any way that without giving the complete path in xsi:noNamespaceSchemaLocation, it can be made to work?
Some sample code-->
String parserName = "org.apache.xerces.parsers.SAXParser";
XMLReader parser = XMLReaderFactory.createXMLReader(parserName);
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 );
ErrorHandler defaultHandler = new SAXErrorHandler();
parser.setErrorHandler(defaultHandler);
XMLReader parser = XMLReaderFactory.createXMLReader(parserName);
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 );
ErrorHandler defaultHandler = new SAXErrorHandler();
parser.setErrorHandler(defaultHandler);
InputSource source = new InputSource(this.getClass().getResourceAsStream("/common/request.xml"));
parser.parse(source);
parser.parse(source);
XML is in directory c:\code\src\common
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/common/schemas/request.xsd">
...
</Request>
</Request>
Schema request.xsd is in directory c:\code\src\common\schemas
Any help will be greatly appreciated...
Regards,
Peter
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
