It's not a secret anymore!*
The moose likes XML and Related Technologies and the fly likes RELATIVE PATH from xsl (cocoon) to apache root for external graphics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "RELATIVE PATH from xsl (cocoon) to apache root for external graphics" Watch "RELATIVE PATH from xsl (cocoon) to apache root for external graphics" New topic
Author

RELATIVE PATH from xsl (cocoon) to apache root for external graphics

Robert Jaeger
Ranch Hand

Joined: Apr 29, 2002
Posts: 62
Hi!
I am generating PDF files (containing images) with Cocoon.
Unfortunately the integration of images (external-graphic) works only on windows and only with absolute path descriptions:

How can I get to my apache [root]/images directory? It doesn�t work with "../". I tried a lot of different paths.
And why Linux doesnt understand the above presented code. Do I have to use back-slashes? Where exactly?
Hope you can help me,
Robert.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
You can set the base directory of the FOP using
/conf/userconfig.xml file
<entry>
<key>baseDir</key>
<value></value>
</entry>


Spritle Software Blogs
Robert Jaeger
Ranch Hand

Joined: Apr 29, 2002
Posts: 62
Thanks for your help!
But I cannot find this file or something similar?
Do you have an idea?
Robert.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Robert Jaeger:
Thanks for your help!
But I cannot find this file or something similar?
Do you have an idea?
Robert.

Actually that file comes with fop package.
If you are using servlet to generate PDF file dynamically for the given xml file... then in your
servlet file try to add the following code before you can the Driver object
String basepath = file:"+getServletContext().getRealPath("/images");
org.apache.fop.configuration.Configuration.put("baseDir",basepath);
this will assign the absolute path to baseDir inspite of windows or unix..

later in your xsl file you can simply call the graphic file name like
<fo:external-graphic src = "test.gif"></fo:external-graphic>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RELATIVE PATH from xsl (cocoon) to apache root for external graphics