Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1587

Wrong images used (how to clear image cache?)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Resolution: Unresolved
    • 0.95
    • None
    • image/unqualified
    • None
    • Operating System: Windows 2000
      Platform: PC
    • 46048

    Description

      The problem: if an (SVG) image with the same file name (but different file path!) is generated more than 1 times, FOP always uses the (wrong) first image.

      We use relative paths in our XSLs to reference SVG images. This worked good in FOP 0.20.5 but doesn't work in FOP 0.95 anymore (well, it works with FOP 0.95 when called via FOP.bat but it doesn't work when called from within a Java app via the FOP Java API). So I wrote a custom URIResolver to change the file name to the current unique file path. This solves the problem of the (so far) not working relative paths for images.

      However, if a subsequent document generates the same report with the same file but with different data, FOP doesn't use the newly generated file content but the old image of the first report. I guess the internal image cache doesn't use the resolved image file name but the first generated one.

      Example:

      1. XSL content:

      <svg:image width="170mm" height="120mm" xlink:href="C_PerfRiskCons_M.svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>

      2. custom URIResolver changes

      'file:/D:/Tmp/iComps/amc/reports/C_PerfRiskCons_M.svg'

      to

      'file:///D:\Tmp\iComps\amc\reports\dVwIIqKYfobFQDzUFJDQ5Er60ovA0G7YMpAVypnaMhY=\C_PerfRiskCons_M.svg'.

      with "dVwIIqKYfobFQDzUFJDQ5Er60ovA0G7YMpAVypnaMhY=" being a unique GUID for each report.

      => it seems FOP 0.95 uses 'file:/D:/Tmp/iComps/amc/reports/C_PerfRiskCons_M.svg' for the image cache which would explain the faulty behaviour.

      I tried to work around this by serializing report generation and clearing the image cache before each report, but there is no org.apache.fop.image.FopImageFactory.resetCache() anymore in FOP 0.95 and I didn't find any other resetCache() method in the API.

      How can I work around this?

      Attachments

        1. uri-preresolution-proposal.patch
          3 kB
          Jeremias Maerki

        Activity

          People

            Unassigned Unassigned
            mhilpert@gmx.de M.H.
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: