forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject Re: Problem with fop94 locating an aart-image
Date Thu, 14 Feb 2008 20:08:16 GMT
On Thu, 2008-02-14 at 16:43 +0100, Ferdinand Soethe wrote:
> I'm currently testing site-author with fop94 and came across 
> this strange problem that in rendering
> /committed.html
> the aart-image
> committed-1.aart (located in xdocs, being called as 
> committed-1.png) renders fine in html but causes this error 
> in rendering fop.

Hmm, in resources.xmap we have:
 <map:match pattern="**.png">
        <map:select type="exists">
          <map:when test="{lm:project.images.{1}.svg}">
            <map:call resource="pipe-aggregate-svg2png-resource">
              <map:parameter name="path"
value="{lm:project.images.{1}.svg}" />
          <map:when test="{lm:project.images.{1}.aart}">
            <map:generate type="asciiart-svg"
src="{lm:project.images.{1}.aart}" />
            <map:call resource="transform-project2text"/>
            <map:serialize type="svg2png" />
          <map:when test="{lm:project.images.{1}.png}">
            <map:read src="{lm:project.images.{1}.png}"
mime-type="image/png" />

were {lm:project.images.{1}.aart} is one of
        <location src="{properties:resources.images}{1}.{2}" />
src="{properties:content}../resources/images/{1}.{2}" />
        <location src="{properties:content.xdocs}images/{1}.{2}" />
        <location src="{properties:content.xdocs}{1}.{2}" />

> ERROR - Image not available: 
> C:\forrest\fop94\site-author/./content/xdocs/committed-1.png

In html this is working but in fop not. It seems that is not matching
the above sitemap snippet.

Looking at http://localhost:8888/committed.html
the link is to <img alt="committer path" src="committed-1.png">

but requesting http://localhost:8888/ I can find:

That explains why the above is never hit.

The reason for the behavior is in document-to-fo.xsl:

!-- Make relative paths absolute -->
      <xsl:variable name="imgpath">
<!-- resources image dir -->
          <xsl:when test="starts-with(string(@src),'images/')">
          <xsl:when test="contains(string(@src),'/images/')">
<!-- already absolute -->
          <xsl:when test="contains(string(@src),':') or
            <xsl:value-of select="@src"/>
<!-- relative to document -->
            <xsl:value-of select="concat($xmlbasedir,@src)"/>

Hacking the last line (within otherwise) to 
<xsl:value-of select="concat('http://localhost:8888/',@src)"/>
will bring back the image (really ugly and bad formated but it is in

My prior hack to <xsl:value-of select="@src"/> did not work because it
seems the resulting document is ignoring the servlet context and use the
relative path from himself. 

The problem as I understand it is that 
<fo:external-graphic src="$absoluteUrl"/> needs an absolute url to
resolve the image. 

However ATM I do not have a good (well thought) solution to resolve this
problem maybe somebody else has some thoughts. 

One possible idea is to do the path resolving via the locationmap. Using
lm://committed-1.png which then should be rewritten to the absolute

One would need to move some logic of the resources.xmap exist matching
to lm matching.

Thorsten Scherler                       
Open Source Java                      consulting, training and solutions

View raw message