commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike O'Leary" <tm-ole...@comcast.net>
Subject Registering a local dtd file for use with Digester
Date Thu, 22 Feb 2007 19:05:47 GMT
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

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message