commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lily <lil...@gmail.com>
Subject Re: how to include an xmlrule file in another xmlrule file
Date Mon, 26 Sep 2005 19:30:56 GMT
After testing I found out the following:

1. absolute path doesn't work here: the underline sax parser can not find
the file.
2. have to use the relative path, which is relative to where you invoke your
class.

So, I guess the parse just append the given file path to its current
executive directory.

As you discoved in the source code, there is no way to set the file location
via current digester interface and a patch to solve this problem will be
greatly appreciated.

Thanks!

Lily

On 9/25/05, Simon Kitching <skitching@apache.org> wrote:
>
> On Fri, 2005-09-23 at 16:22 -0400, Lily wrote:
> > Hello,
> >
> > I am using the <include path=""/> to import a xmlrule file into another
> rule
> > file, but it always give me a
> >
> > org.apache.commons.digester .xmlrules.XmlLoadException: Error at (6, 37:
> > File "rules2.xml" not found.
> > java.lang.NullPointerException
> >
> > I have tried to use the full path to rules2.xml or relative path, but
> none
> > of them worked.
>
> >From a peek at the code, it looks like in the <include> tag you would
> have to specify either an absolute URL (eg "file:/foo/xmlrules2.xml") or
> would have to specify a URL which is relative to the *current working
> directory* of the application.
>
> This code is from o.a.c.d.xmlrules.FromXmlRuleSet:
> /** Loads XMLRules from an URL */
> private class URLXMLRulesLoader extends XMLRulesLoader {
> private URL url;
> public URLXMLRulesLoader(URL url) {
> this.url = url;
> }
>
> public void loadRules() throws XmlLoadException {
> try {
> rulesDigester.parse(url.openStream());
> } catch (Exception ex) {
> throw new XmlLoadException(ex);
> }
> }
> }
>
> The rulesDigester object is a Digester used to process the xmlrules
> file. The call to parse(url.openStream) isn't giving that digester
> instance any hints about where the file it is parsing is (just an open
> stream) so that digester couldn't possibly resolve any relative paths in
> the xmlrules file except by using the current working directory as a
> base.
>
> Sure looks to me like a patch would be a nice idea. I don't use xmlrules
> though, so probably won't write it myself.
>
> Regards,
>
> Simon
>
>

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