I have a collection of XML files that I would like to parse using Digester
in order to index them for Lucene. A DTD file has been supplied for the XML
files, but none of those files has a <!DOCTYPE ...> line associating them
with the DTD file. Can the Digester's register function be used to tell it
to use that DTD file for such things as entity resolution? If so, how do I
do it? I don't understand how to specify a pathname for a local file in
terms of a publicId and an entityURL.

 

Alternatively, can I use setEntityResolver to perform entity resolution
instead? I tried to do this, with code like the following:

 

        Digester       digester = new Digester();

        EntityResolver myEntityResolver = new MyEntityResolver();

        

        digester.setEntityResolver(myEntityResolver);

 

where MyEntityResolver is defined elsewhere as a class that implements
EntityResolver. To start with, I just had the MyEntityResolver.resolveEntity
function return null, but when the parser hit an unknown entity, it just
threw an exception saying that an entity was referenced but not defined,
without ever calling MyEntityResolver.resolveEntity. Did I leave something
out? In any case, if I wanted the entities resolved according to the
definitions in the DTD file (instead of just returning null), is there a way
to provide that information to the entity resolver, or is it better to use
the register function for that purpose? Thanks.

Mike O'Leary

Reply via email to