Re: Defaulting to current directory

Jochen Wiedmann <[email protected]> Fri, 16 Jul 2004 07:59:49 +0200
Newsgroups gmane.text.xml.sax.devel
Message-ID <[email protected]>
Yuval Oren wrote:

> What should the following Java code do if run in the same directory as=20
> doc.xml and doc.dtd? Should it be able to find doc.dtd?

[...]

> reader.parse(new InputSource(new FileInputStream(=93doc.xml=94)));

I would personally assume, that you have to use

     InputSource isource =3D new InputSource(new FileInputStream("doc.xml=
"));
     isource.setSystemId("doc.xml");
     reader.parse(isource);

because otherwise there is no such thing like a "base URI".


> Case 2 =96 JAXP:
>=20
> SAXParser parser =3D ...;
>=20
> parser.parse(new FileInputStream(=93doc.xml=94), new DefaultHandler());

In that case, I believe that

     parser.parse(new File("doc.xml"), new DefaultHandler());

will do the same, because this is implicitly creating an InputSource like=
 above.


Jochen


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
List: sax-devel, [email protected]
See:  http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel