You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Brian Kuhn <bn...@gmail.com> on 2005/11/08 20:30:50 UTC

specify xerces basedir?

Hi all,

I need to run some targets on a legacy build script. I'm running them from a
new build script in another directory using the 'ant' task. Unfortunately,
the legacy script uses XML entity includes and I'm getting
FileNotFoundExceptions when I run the targets. It seems like my xml parser
(I've tried Xerces 1.3 and 2.x) is using the directory of my new script
(where the JVM was started) as its base directory. Does anyone know of a way
to tell Xerces to use the legacy script's base directory? Is there another
way to fix my problem?

Thanks,
Brian


ps - I cannot edit the legacy script or upgrade Ant to 1.6 and use the
import task...

Re: specify xerces basedir?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 8 Nov 2005, Dominique Devienne <dd...@gmail.com> wrote:
>> > Does anyone know of a way to tell Xerces to use the legacy
>> > script's base directory?
>>
>> Ant installs an EntityHandler that resolves relative file URIs
>> relative to the basedir, but if your legacy build uses the wrong
>> form of URI (i.e. it doesn't use file: at all), you are out of
>> luck.
> 
> But Stefan, relative XML entities are supposed to be relative to the
> file that declares them, not relative to basedir, for that builds,
> or its parent. Am I missing something?

You are correct, this is the code

            if (systemId.startsWith("file:")) {
                String path = FILE_UTILS.fromURI(systemId);

                File file = new File(path);
                if (!file.isAbsolute()) {
                    file = FILE_UTILS.resolveFile(context.getBuildFileParent(), path);
                }

so relative file: URIs get resolved relative to the build file, not
relative to basedir.

Thanks for correcting me.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: specify xerces basedir?

Posted by Dominique Devienne <dd...@gmail.com>.
> > Does anyone know of a way to tell Xerces to use the legacy script's
> > base directory?
>
> Ant installs an EntityHandler that resolves relative file URIs
> relative to the basedir, but if your legacy build uses the wrong form
> of URI (i.e. it doesn't use file: at all), you are out of luck.

But Stefan, relative XML entities are supposed to be relative to the
file that declares them, not relative to basedir, for that builds, or
its parent. Am I missing something? --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: specify xerces basedir?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 8 Nov 2005, Brian Kuhn <bn...@gmail.com> wrote:

> Does anyone know of a way to tell Xerces to use the legacy script's
> base directory?

Ant installs an EntityHandler that resolves relative file URIs
relative to the basedir, but if your legacy build uses the wrong form
of URI (i.e. it doesn't use file: at all), you are out of luck.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org