Nico Seessle wrote:

> The documentation (the "Digester Developer Guide") says:
> 
> "For example, the Struts framework controller servlet uses the following
> registration in order to tell Struts to use a local copy of the DTD for the
> Struts configuration file. This allows usage of Struts in environments that
> are not connected to the Internet, and speeds up processing even at Internet
> connected sites (because it avoids the need to go across the network).
>     digester.register
>       ("-//Apache Software Foundation//DTD Struts Configuration 1.0//EN",
>        "/org/apache/struts/resources/struts-config_1_0.dtd");
> 
> As a side note, the system identifier used in this example is the path that
> would be passed to java.lang.ClassLoader.getResource() or
> java.lang.ClassLoader.getResourceAsStream(). The actual DTD resource is
> loaded through the same class loader that loads all of the Struts classes --
> typically from the struts.jar file."
> 
> but it does not seem that it tries to get the dtd thru getRessource() - is
> this true?

This is true.  The documentation is correct. Right now, the 
resolveEntity function expects all DTDs registered to be URLs.  So, we 
have 2 choices:

1) Change register from:


  public void register(String publicId, String dtdURL)

to:

 public void register(String publicId, URL dtdURL)

where you would provide the URL, or we can overload this, so that the 
first version turns the string into an URL using getResource().

I think that the resolveEntity() code should remain the same, and the 
dtds HashMap should contain URL objects, not Strings.

I am for overloading register to provide both pieces of functionality. 
What do you think, Craig?

> 
> At least on W2K/JDK1.3 it seems I need to register the DTD using something
> like
> 
>   digester.register("-//HM ORGA Software GmbH//Persistence 1.0//EN",
> 
> "file:///H:/VAMOS50/Source-NS/DigesterTest/classes/de/hmorga/tools/xml2dbo/p
> ersistence_1_0.dtd");
> 
> Am I doing something wrong, or is this a bug in the docs?

This is a bug in the docs.  Thanks for pointing it out.  The workaround 
for now until I patch this is to call register like this:

   digester.register("whateverTheSystemIDIs",
    getClass.getResource("/org/apache/....").toString());

or something to that effect.

Scott Sanders

Reply via email to