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]

Reply via email to