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: JBryant@xxxxxxxxx
Date: Thu, 7 Apr 2005 15:48:11 -0500
Hi, Josh,

Are you trying to get a path from a parameter that you pass to the XSL 
stylesheet?

If so, you'd have a structure like the following (though with much more 
meat on its bones, of course):

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:param name="path"/>

  <xsl:template match="/">
    <!-- all the stuff to make an FO document here -->
      <fo:external-graphic src="{$path}"/>
    <!-- and more here -->
  </xsl:template>

</xsl:stylesheet>

You'd have to do a two-step process to invoke it, thus:

xalan -in mydoc.xml -xsl myxsl.xsl -out out.fo -param path 
somewhere/over/the/rainbow.gif
fop out.fo out.pdf

(I forget whether the parameter value needs quotation marks. I use Saxon 
rather than Xalan, and Saxon handles parameters differently.)

If you're creating PDF documents to respond to requests through a web 
server, that won't work, of course, but I hope it gives you an insight 
into what to do.

Also, all the things that the other folks have said about valid URLs and 
such apply. And you may need the url function, as in src="{url($path)}". 
However, this arrangement can work, provided you are passing in something 
that resolves to the location of an image file. 

I suggest you ask this question on the FOP list, btw. It's maintained by 
SourceForge.

HTH

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

Current Thread