Hi Craig

    <!ENTITY part1 SYSTEM "part1.xml">

was what I started off with, but it didn't work. Then I tried

    <!ENTITY part1 SYSTEM "file:part1.xml">

but no joy. Finally I tried:

    <!ENTITY part1 SYSTEM "file:C:\projects\test\WEB-INF\part1.xml">

it worked!

I would really like to use

    <!ENTITY part1 SYSTEM "part1.xml">

but I still get the exception File part1.xml not found.

Can you assist further?

Regards
Keith



-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 February 2002 6:22 a.m.
To: Jakarta Commons Developers List
Subject: Re: Digester and Struts...


There is a part of this that is parser-related and part that is Digester
related.  See intermixed responses below.

On Mon, 25 Feb 2002, Keith Chew wrote:

> Date: Mon, 25 Feb 2002 18:07:18 +1300
> From: Keith Chew <[EMAIL PROTECTED]>
> Reply-To: Jakarta Commons Developers List <[EMAIL PROTECTED]>
> To: Jakarta Commons Developers List <[EMAIL PROTECTED]>
> Subject: Digester and Struts...
>
> Hi
>
> I have having a problem with the Digester package. Using Struts, I have
> edited the struts-config.xml file to:
>
> <?xml version="1.0"?>
> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
> Configuration 1.0//EN"
>           "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"; [
>
>     <!ENTITY part1 SYSTEM "file:part1.xml">
>     <!ENTITY part2 SYSTEM "file:part2.xml">
>     <!ENTITY part3 SYSTEM "file:part3.xml">
> ]>
>

The above URLs assume that your webapp is running in an unpacked directory
that can be accessed with file I/O -- a dubious assumption in many servlet
containers.  Try a relative URL like this:

    <!ENTITY part1 SYSTEM "part1.xml">

instead.  That way, the URL is explicitly recognized as being relative to
the owning document, whatever it's URL is -- and it won't be a file URL if
you do something like this to create the input stream:

  InputStream is =
    getServletContext().getResourceAsStream("/WEB-INF/struts-config.xml");

This is what Struts does.

> <struts-config>
>       <form-beans>
>         &part1;
>       </form-beans>
>
>       <global-forwards>
>         &part2;
>       </global-forwards>
>
>       <action-mappings>
>         &part3;
>       </action-mappings>
> </struts-config>
>
> where part1.xml, part2.xml and part3.xml are in the same folder as
> struts-config.xml.
>
> I get the exception File part1.xml cannot be found.
>
> I have reported this to the Xerces mailing list and they said that before
> parsing the file, you need to set the systemId, eg:
>
> source.setSystemId("file:" + getServletConfig().getAbsolutePath() + "/" +
> fileName);
>

Well, this doesn't exactly work because there is no "getAbsolutePath()"
method on the ServletConfig interface.  The closest analog would be:

  source.setSystemId("file:" + getServletContext().getRealPath("/") + "/"
    + fileName);

However, that still sticks you with using file i/o exclusively -- and this
solution doesn't help you for Struts in any case because it doesn't use
the InputSource option for processing input.

You're much better off using actual relative URLs, as described above.

> This will allow the part1.xml, part2.xml and part3.xml to be found.
Looking
> at the Digester class, it does not do this. Can we fix this problem?
>
> Keith
>

Craig


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to