Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Robert Jaeger
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the base directory of the FOP using
/conf/userconfig.xml file
<entry>
<key>baseDir</key>
<value></value>
</entry>
 
Robert Jaeger
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic