Re: [xsl] xsl display graphic from xml

Subject: Re: [xsl] xsl display graphic from xml
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Thu, 7 Apr 2005 13:37:25 -0500
> I want to get the string returned from
> the template logo and use it for the url.  Ideas?
> This is what I have.
> 
> <xsl:template name="logo">
>         <xsl:value-of select="invoice/images/logo"/>
> </xsl:template>
> 
> <xsl:template name="getLogo">
>         <fo:external-graphic src="url( D:\simple\logo.jpg)"/>
> </xsl:template>
> 

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