forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thors...@apache.org>
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:call>
          </map:when>
          <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>
          <map:when test="{lm:project.images.{1}.png}">
            <map:read src="{lm:project.images.{1}.png}"
mime-type="image/png" />
          </map:when>
        </map:select>
      </map:match>

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


> 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/committed.fo I can find:
<fo:external-graphic
src="/home/thorsten/src/apache/forrest/trunk/site-author/./content/xdocs/committed-1.png"/>

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">
        <xsl:choose>
<!-- resources image dir -->
          <xsl:when test="starts-with(string(@src),'images/')">
            <xsl:value-of
select="concat($imagesdir,substring-after(@src,'images'))"/>
          </xsl:when>
          <xsl:when test="contains(string(@src),'/images/')">
            <xsl:value-of
select="concat($imagesdir,substring-after(@src,'/images'))"/>
          </xsl:when>
<!-- already absolute -->
          <xsl:when test="contains(string(@src),':') or
starts-with(string(@src),'/')">
            <xsl:value-of select="@src"/>
          </xsl:when>
<!-- relative to document -->
          <xsl:otherwise>
            <xsl:value-of select="concat($xmlbasedir,@src)"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

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
there).

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
URL. 

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

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


Mime
View raw message