Bug 14948 - [PATCH] Resolution of relative URLs in FopImageFactory
Summary: [PATCH] Resolution of relative URLs in FopImageFactory
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: images (show other bugs)
Version: 0.20.4
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-29 07:19 UTC by Manuel Mall
Modified: 2012-04-01 06:28 UTC (History)
0 users



Attachments
Diff of FopImageFactory.java (2.00 KB, patch)
2002-11-29 07:21 UTC, Manuel Mall
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Mall 2002-11-29 07:19:38 UTC
Christian,

This was actually discussed as part of Bug 13866 but really should have been 
separated. Repeated partially here:

==== Start of copy from Bug 13866 ====

------- Additional Comments From Manuel Mall 2002-11-19 01:20 -------
....

Regarding the resolving of URIs in FopImageFactory you say it works for you 
under Linux. I can say it doesn't work for me under Linux. Could it be that we 
are using different JDKs (I use IBM 1.3.0) and that the behaviour of the URL 
constructor "new URL(context, spec)" has changed? Any way, what I observe is 
that if basedir is something like "file:/..." and the URL in the external-
graphics tag is also "file:/...", ie. has the protocol included (which it has 
for all the FOP examples), then the constructor mentioned above does not 
resolve any relative paths in "spec" as it contains a protocol component which 
according to the URL RFC means it is an absolute URL.


------- Additional Comments From Christian Geisert 2002-11-28 14:01 -------

I just had a look a the current source with regards to relative URLs.

The relative part is done with a URL.getFile() which returns the path
without "file:" on the Sun JDK. Is this different with the IBM JDK?

==== End of copy from Bug 13866 ====

I just got the latest maintenance branch CVS build it and then tried to build 
the doc/examples which returned errors for all images. To explain the error I 
added one line of debug statement to FopImageFactory. Here is the log for the 
first example:

      [fop] /home/mm/fop-dev/xml-fop/docs/examples/fo/bgimage.fo -
> /home/mm/fop-dev/xml-fop/docs/examples/tests/bgimage.pdf
      [fop] [INFO] building formatting object tree
      [fop] [INFO] setting up fonts
      [fop] baseURL=file:/home/mm/fop-dev/xml-fop/docs/examples/fo/ 
absoluteURL.getFile()=/graphics/xml_feather_transparent.gif 
absoluteURL=file:/graphics/xml_feather_transparent.gif
      [fop] Error creating background image: Error while recovering Image 
Informations 
(file:/graphics/xml_feather_transparent.gif) : /graphics/xml_feather_transparent
.gif (No such file or directory)
      [fop] [INFO] [1]
      [fop] baseURL=file:/home/mm/fop-dev/xml-fop/docs/examples/fo/ 
absoluteURL.getFile()=/graphics/linux.bmp absoluteURL=file:/graphics/linux.bmp
      [fop] Error creating background image: Error while recovering Image 
Informations (file:/graphics/linux.bmp) : /graphics/linux.bmp (No such file or 
directory)      

The actual URLs used in bgimage.fo are:
    "file:../../graphics/xml_feather_transparent.gif"
    "file:../../graphics/linux.bmp"
Obviously they are not correctly resolved.

I then reapplied the part of the patch (originally provided with bug 13866) 
which deals with these relative URLs and now it works for me.

      [fop] /home/mm/fop-dev/xml-fop/docs/examples/fo/bgimage.fo -
> /home/mm/fop-dev/xml-fop/docs/examples/tests/bgimage.pdf
      [fop] [INFO] building formatting object tree
      [fop] [INFO] setting up fonts
      [fop] baseURL=file:/home/mm/fop-dev/xml-fop/docs/examples/fo/ 
href=../../graphics/xml_feather_transparent.gif absoluteURL=file:/home/mm/fop-
dev/xml-fop/docs/graphics/xml_feather_transparent.gif
      [fop] [INFO] [1]
      [fop] baseURL=file:/home/mm/fop-dev/xml-fop/docs/examples/fo/ 
href=../../graphics/linux.bmp absoluteURL=file:/home/mm/fop-dev/xml-
fop/docs/graphics/linux.bmp
Comment 1 Manuel Mall 2002-11-29 07:21:49 UTC
Created attachment 3985 [details]
Diff of FopImageFactory.java
Comment 2 Christian Geisert 2002-12-09 01:01:17 UTC
Committed, thanks.
Comment 3 Glenn Adams 2012-04-01 06:28:10 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed