You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Steiner, Priska" <Pr...@ipi.ch> on 2002/07/24 16:32:16 UTC

Image Source with FOPServlet

Hello 

I would like to make a report with an image in it. When I render the xml and
the xsl with the image source,  with FOP 0.20.4 out a commandline, it works
fine. But I have to render it, with exactly the same files in a FOPServlet.
There it gives me a NullPointerException.


In the xml it is as follows:

<bild src="c:\xsl\bild_1200011229.jpg" width="50" height="50"></bild>

In the xsl I do it with an external graphics element:

<xsl:template match="bild">
	 <fo:block text-align="center">
		<fo:external-graphic src="file:{@src}"/>
  	</fo:block>
</xsl:template>

Is there any idea, what the problem is ?

Regards
P. Steiner



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Image Source with FOPServlet

Posted by Michael Gratton <mj...@recalldesign.com>.

Steiner, Priska wrote:
> 
> I would like to make a report with an image in it. When I render the xml and
> the xsl with the image source,  with FOP 0.20.4 out a commandline, it works
> fine. But I have to render it, with exactly the same files in a FOPServlet.
> There it gives me a NullPointerException.

Taking a wild stab in the dark (you'd probably want to provide a stack 
trace for a more accurate guess.. :), the generated file URL isn't valid.

Your file URL will end up looking like:

   file:c:\xsl\bild_1200011229.jpg

There are a few problems with this. First, the URL doesn't have a 
leading '/', or an authority part. Eg:

   file:///c:\xsl\bild_1200011229.jpg

or at least:

   file:/c:\xsl\bild_1200011229.jpg

Next, the ':' character the 'c' is (IIRC) invalid for a URL at that 
point, and either needs to be escaped or replaced with something valid 
(a '|' is usally used)

   file:/c|\xsl\bild_1200011229.jpg

or

   file:///c%3A\xsl\bild_1200011229.jpg

Lastly, you've used '\' as the path separator, not '/', which is also 
invalid in a URL. So, in the end, the URL shoulddl look like:

   file:///c|/xsl/bild_1200011229.jpg

Either you'll want to modify your XML to use a valid URL path component 
and your XSLT to use prepend "file:///" instead of just "file:", or 
modify your XSLT to fixup the Windows file path, turning it into a valid 
URL path component as part of the transformation.

I don't know how lax the JRE on Windows is WRT strict parsing of file 
URLs, but if you fix up all of the above, at least you'll know you're 
referencing your image correctly. :)

HTH,
/mike

-- 
Michael Gratton <mj...@recalldesign.com>
Recall Design <http://www.recalldesign.com/>
s: 53 Gilbert Street Adelaide SA 5000 Australia
t: +61 8 8217 0500 f: +61 8 8217 0555