You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by L Duperval <du...@videotron.com> on 2010/05/07 21:22:38 UTC
redirect:write output path
Hi,
I am using the redirect:write extension and I am trying to figure out how to
specify the absolute path for the transformation output.
In my Java code I do this:
transformer = tFactory.newTransformer(new StreamSource(
MeteoMediaForecastTransform.class.getResourceAsStream("/xsl/my.xsl")));
transformer.setParameter("outputDir",outputDirectory);
transformer.transform(new StreamSource(
inputFile), new StreamResult(
System.out));
where outputDirectory is an absolute path. Yet, when I execute the
transformation, the output is saved relative to the location of the input file.
Any idea what I am doing to cause this?
I am using xalan 2.7.1 with JDK 1.6.0.20.
Thanks,
L
Re: redirect:write output path
Posted by L Duperval <du...@videotron.com>.
<keshlam <at> us.ibm.com> writes:
>
> > MeteoMediaForecastTransform.class.getResourceAsStream("/xsl/my.xsl")));
> The value is a URI. If you want it to be interpreted
> as an absolute URI, it must include a URI Scheme. Since you want to write
> to the filesystem, use the file: scheme... and if this is a Microsoft operating
> sytem, probably a drive letter as well:
> "file:///C:/xsl/my.xsl"
>
>
Thanks for the reply. I tried a few variations and the culprit seems to be the
following:
transformer.setParameter("outputDir",outputDirectory);
transformer.transform(new StreamSource(inputFile),
new StreamResult(System.out));
I am on a Windows machined and if I specify the output directory as "C:/foo" it
writes to the correct location, however, if I set it simply to "/foo" it writes
it in the location relative to the input file.
The problem is that the redirect:write parameter accepts a file, not a URI as a
parameter. When I specify c:/ on a Windows system, it will force the write to
the proper location, but in the end the application will be running on a Unix
(Linux?) system. The root file system will be specified as "/" which will
probably exhibit the same problems (I can't confirm for sure because I don't
have a machine to test with available).
When I run the application outside of a container (tomcat in my case, but
eventually WAS) I don't see this behaviour. The "/" is interpreted correctly as
the root of the current file system.
So I think I'm still stuck.
L
Re: redirect:write output path
Posted by ke...@us.ibm.com.
> MeteoMediaForecastTransform.class.getResourceAsStream("/xsl/my.xsl")));
The value is a URI. If you want it to be interpreted as an absolute URI,
it must include a URI Scheme. Since you want to write to the filesystem,
use the file: scheme... and if this is a Microsoft operating sytem,
probably a drive letter as well:
"file:///C:/xsl/my.xsl"