Hi Brad,
Your message seems to say that you 've read Andy as saying that the entityResolver is opening not the entity file but the XML document itself. This is not how I read his message (or understand it): the entityResolver opens the entity (DTD file). So it never needs to know the URI of the XML document; it just cares about the publicId and systemId of the document in question, which the parser feeds it. Hope that helps, Neil Neil Graham XML Parser Development IBM Toronto Lab Phone: 416-448-3519, T/L 778-3519 E-mail: [EMAIL PROTECTED] "Brad O'Hearne" <[EMAIL PROTECTED]> on 02/20/2001 03:15:40 AM Please respond to [EMAIL PROTECTED] To: <[EMAIL PROTECTED]> cc: Subject: RE: EntityResolver/Windows Paths -- [ WAS: Windows Paths] Thanks a bunch. I had wondered if the InputSource that was supposed to be returned from the resolveEntity was for the XML file itself, or for the DTD, in which case the parser had already created another separate InputSource for the XML file. This makes more sense now. However, I am interested in one other detail. I passed in the uri of the XML file to the parser.parse(uri) method. In the EntityResolver, I do not know what the uri to the XML file is -- I only know the uri of the dtd (via the systemId). I suppose that I will have to set this at the time I create the EntityResolver (i.e. create a constructor in the EntityResolver, pass the uri in, etc.). However, if I am required not only to resolve the dtd in the EntityResolver, but also create the InputSource for the xml file itself in the resolveEntity method, wouldn't it make sense to pass the uri of the xml file itself as a parameter to the resolveEntity method? It seems strange that in passing this xml uri to the parser.parse(uri) method, we not only lose this information but need to have it supplied by some other means to the EntityResolver. Does this sound like a good idea? Brad -----Original Message----- From: Andy Clark [mailto:[EMAIL PROTECTED] Sent: Monday, February 19, 2001 6:20 PM To: [EMAIL PROTECTED] Subject: Re: EntityResolver/Windows Paths -- [ WAS: Windows Paths] Brad O'Hearne wrote: > However, if my xml file is c:\test\data.xml, and my dtd is c:\dtd\data.dtd, > and I try the following line, after it returns the XMLReader will throw a > NullPointerException: I haven't really looked into your problem in detail but it sounds like the parser is assuming that you are going to open the entity in your entity resolver. So when you just create an InputSource object with a new system id, the parser asks for the input stream (or reader) which is null and this causes a NullPointerException to be thrown. Since you know the location of your file, why don't you open the stream yourself? For example: public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { // we know the location of this entity if (systemId.endsWith("data.dtd")) { InputStream stream = new FileInputStream("c:\\test\\data.dtd"); InputSource source = new InputSource(stream); source.setPublicId(publicId); source.setSystemId(systemId); return source; } // can't resolve, let parser try to find it return null; } -- Andy Clark * IBM, TRL - Japan * [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
