On Wed, 20 Feb 2002, Benoit Segaert wrote:

> Date: Wed, 20 Feb 2002 11:35:31 +0100
> From: Benoit Segaert <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: Re: How can I register a DTD in a war
>
> Thanks Jan,
>
> But I would like to avoid the server name http://127.0.0.1:XXXX or any
> access to a specific server.
>
> When I use Struts in my application, I have the following config file
> <?xml version="1.0" encoding="ISO-8859-1" ?>
>
> <!DOCTYPE struts-config PUBLIC
>           "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
>           "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";>
> <struts-config>
>
> If I see the Tomcat log I can see:
>
> register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN',
> 'jar:file:C:/java/jakarta-tomcat-4.0.1/webapps/strutsjndi/WEB-INF/lib/struts.jar!/org
>
> /apache/struts/resources/struts-config_1_0.dtd'
>
> You can see the struts.jar contains the dtd but in the xml file the
> reference is the
> following:
>     "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";
>
> I want to reproduce this configuration.
> Can you help me?
>

You could look at how Struts does this (via the Digester package from
Jakarta Commons):

  http://jakarta.apache.org/commons/digester.html

Basically, Digester does a SAX parse of the XML document.  In the SAX
APIs, you can define your own EntityHandler, where the resolveEntity()
method will be called by the parser when the DOCTYPE is encountered.  I
just keep an internal registration table that says, "whenever you see the
following public identifier, use *this* URL for the system identifier
instead of the one in the document."

Details are in the Digester source code, which is accessible via the link
above.

By the way, Tomcat uses the same trick to reference an internal copy of
the DTD for your web.xml and TLD files - that's why you can run Tomcat on
a machine disconnected from the Internet.

> Benoit
>

Craig


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to