You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Wong Kok Wai <wo...@pacific.net.sg> on 2000/02/20 09:34:30 UTC

Unable to re-use entity resolver

When I parse two documents that uses the same DTD consecutively, and I
use the same instance of my implementation of EntityResolver, a "stream
closed" exception is thrown. The workaround is to create a new instance
for each document. This is rather inefficient as the same DTD is used
and one instance of entity resolver implementation is sufficient IMHO.
Is this a feature or a bug?


Re: Unable to re-use entity resolver

Posted by Andy Clark <an...@apache.org>.
Wong Kok Wai wrote:
> When I parse two documents that uses the same DTD consecutively, 
> and I use the same instance of my implementation of EntityResolver, 
> a "stream closed" exception is thrown. The workaround is to create 
> a new instance for each document. This is rather inefficient as the 
> same DTD is used and one instance of entity resolver implementation 
> is sufficient IMHO. Is this a feature or a bug?

You can use the same instance of your EntityResolver but it
sounds like you're caching the same instance of the returned
InputSource. Is this true? If you are caching the DTD to
return from the EntityResolver, you should cache the entire
contents of the stream into memory and then create new
InputSource objects whose input stream read from memory.
Every call to EntityResolver should return a new InputSource.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org