Hi Michael,
              Thanks, it worked for me.
              So it means schema should be relative to systemId path and it cann't be the other way, that is if xml is in c:\code\src\common\schemas and schema is in c:\code\src\common, then setting systemId will also not work, in that case I have complete path of schema in the xsi:noNamespaceSchemaLocation="c:\code\source\common\request.xsd"
 
Can I buy this?
 
Thanks once again.
 
Regards,
Peter

Michael Rafael Glavassevich <[EMAIL PROTECTED]> wrote:
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
>
> ...
>

> 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]



Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Reply via email to