Re: [xsl] xsl can't get graphic to load from xml file

Subject: Re: [xsl] xsl can't get graphic to load from xml file
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Thu, 7 Apr 2005 15:43:26 -0500
Errr, it looks like you sent two emails to the email list with almost
the exact same subject and the exact same body text.

I responded to the other one, but I don't know if you read
that....I'll add it below, but this is bound to be confusing if
someone looks in the archive.  It is possible, although you might have
to play with the code I have below.

What I believe Eliot is trying to warn you about is that the approach
you are taking is not very flexible.  If you generate the fo document
at a separate time from when you process the fo file (the output from
the xslt transformation) there is the possibility that the path to the
image is no longer correct.  Say you generate fo on system x using
your system.  The url to those documents then change (someone moves
the images up  a folder).   If you then attempt to create a pdf from
the fo file you'll find your images are gone.

Remember, XSLT and XSL-FO are different specs (although they are XSL)
and many people use one without the other.  I'd recommend again that
you try to separate out when you're using xslt to produce an xsl-fo
document and when you are using the xsl-fo document to create another
document.  They are two different processes.  I find that it helps the
learning process if you keep them separate.  Otherwise it can get too
confusing.



==========================================================
Text of my response to your other posting below 
==========================================================

So...is there a reason you need to use that template setup?

Why not just
<xsl:template name="getLogo">
      <fo:external-graphic src="url({invoice/images/logo})"/>
</xsl:template>

Or even better yet:
<xsl:template match="logo">
   <fo:external-graphic src="url({.})"/>
</xsl:template>

If you absolutely must use the two templates, why not something like
(might vary a bit depending on how you treat namespaces I think) :

<xsl:template name="logo">
        <xsl:value-of select="invoice/images/logo"/>
</xsl:template>

<xsl:template name="getLogo">
         <xsl:element name="fo:external-graphic">
                         <xsl:attribute name="src">
                            <xsl:text>url(</xsl:text>
                            <xsl:call-template name="logo"/>
                            <xsl:text>)</xsl:text>
                         </xsl:attribute>
          </xsl:element>
</xsl:template>

Plus, you may want to keep in mind the earlier advice on this list
about not all processors working with the path information you're
using.  Try to provide an actual url (should have that file:// on the
start)

Jon G.

Current Thread