Paul Sorenson wrote:

  
There is important difference b/w the two. In the first case you are
providing character stream and in 2nd case you are providing file path.
When you specify filepath parser knows against what path to resolve
entity references but not in the first case when you are providing the
charater/byte stream. Try setting the systemId in the first case like
src.setSystemId() and it should work in first case too.
    

Thanks for the tip.  If your assertion is correct I don't understand why the
first level schema is ok (as far as it gets) but the second one isn't.
  
If no systemId is set and no entity resolver is set parser tries to resolve the relative location against the working directory. It is possible that the way you have kept your schemas first level schema can be retrieved when resolved against working directory.
Secondly, if the byte stream is provided to the parser why does it also need
to know its location -
It needs the location to resolve relative references. Refer to SAX documentation for more details.
http://www.saxproject.org/apidoc/org/xml/sax/InputSource.html#setSystemId(java.lang.String)
 that would kind of make the FileReader constructor
somewhat superfluous wouldn't it?

  
In your context yes, you can give filepath and parser will take care rest. But that's not always the case, you might get your XML document across the wire as stream. In that case you can wrap stream and give the inputsource object to the parser.


Neeraj

Reply via email to