Hi Peter,
'/common/schemas/request.xsd' is a relative URI, but the leading slash,
makes the path absolute so it won't be resolved against the base path. If
your XML document is located in c:\code\source\common, then your schema
location should be 'schemas/request.xsd', and if you're setting the system
ID on your InputSource, it should be 'file:///c:/code/source/common/' for
this example.
Hope that helps.
-----------------------------------------
Michael Glavassevich
[EMAIL PROTECTED]
Candidate for Bachelor of Applied Science
Computer Engineering
University of Waterloo
On Tue, 3 Jun 2003, peter peter wrote:
> 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);
>
> InputSource source = new
> InputSource(this.getClass().getResourceAsStream("/common/request.xml"));
>
> 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>
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]