Just some further thoughts.

Your DTDResolver class is very confusing because you have publicId as both a
field in the class and as a method parameter to the resolveEntity method.
Simplify your DTDResolver class to look like this:

class DTDResolver implements EntityResolver
{
  public InputSource resolveEntity (String publicId, String systemId)
  {
    InputStream inputStream = null;
    InputSource source = null;

    try
    {
      System.out.println("publicID is: " + publicId);
      System.out.println("systemID is: " + systemId);
 
      if(StringUtils.isNotEmpty(publicId))
      {
        // Next line should be the URL you actually want       
        URL url = new URL(publicId);
        System.out.println("URL is: " + url);
        inputStream = url.openStream();
        System.out.println("got the inputstream");
        source = new InputSource(new InputStreamReader(inputStream));
      }
      else
      { 
        System.out.println("publicId is not specified!!!");
      }
    }
    catch (Exception e)
    {
      System.out.println("Caught exception " + e);
      e.printStackTrace();
    }
  }
} // end DTDResolver class

BTW, InputSource can take in the inputStream directly.  No need to construct
the InputStreamReader yourself.

HTH,
Gary

> -----Original Message-----
> From: Gary L Peskin [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 17, 2003 11:34 AM
> To: 'Pramodh Peddi'; [EMAIL PROTECTED]
> Subject: RE: resolving DTDs while transforming
> 
> 
> Pramodh --
> 
> The entity resolver is not called by your code but by the 
> parser itself when it encounters the !DOCTYPE declaration.  
> You shouldn't be calling any of the setXXX methods in 
> DTDResolver yourself.
> 
> Does your DTDResolver.resolveEntity method ever get called? 
> Does the java statement
> 
>   System.out.println("publicID is: " + this.publicId);
> 
> result in any output?
> 
> I'd also add in a System.out.println() for the systemID.
> 
> Step 1 is to determine if the method is even getting called.  
> If so, we'll need to look at both arguments passed into that method.
> 
> HTH,
> Gary

Reply via email to