Hi Alexandre,
Well, mea culpa, I posted a link to recipe for Saxon 8 processor which is not used by XEP. The XEP formatter is using Saxon 6.5.
Anyway the posted link is a successor of the thread that does contain a solution for your problem. See here:
http://www.biglist.com/lists/xsl-list/archives/200006/msg01332.htmlHere is a snippet ready to use.
<xsl:template name="file.check" xmlns:file="java.io.File" >
<xsl:param name="filename" />
<xsl:choose>
<xsl:when test="function-available('file:new')">
<xsl:variable name="fileobj"
select="file:new($filename)" />
<xsl:choose>
<xsl:when test="not(file:exists($fileobj))">
<xsl:value-of select="true()"/>
<xsl:message>
<xsl:text>File name='</xsl:text>
<xsl:value-of select="$filename" />
<xsl:text>' exists.</xsl:text>
</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
<xsl:message>
<xsl:text>File name='</xsl:text>
<xsl:value-of select="$filename" />
<xsl:text>' does not exist.</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>WARNING : unable to call function 'file:new'</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
See attached stylesheet for example how to use it.
Respectfully,
Volodymyr Rodymyuk
> -----Original Message-----
> From:
www-xsl-fo-request@... [mailto:
www-xsl-fo-request@...] On
> Behalf Of axdmoraes
> Sent: Thursday, September 13, 2007 3:57 PM
> To:
www-xsl-fo@...
> Subject: Re: external-graphic
> I´m using xep 4.10..
> Alexandre
> Tony Graham-3 wrote:
> >> I tryed this:
> >>
> >> <xsl:variable name="absoluteURI" select="resolve-uri(@src,
> >> base-uri(.))" as="xs:anyURI"/>
> >> But it didn´t work.
> > resolve-uri() is an XPath 2.0 function, and it appears that you are
> > using an XSLT 1.0 processor since it doesn't recognise the "as"
> > attribute.
> >
> > To use Michael Kay's example in his XSL-List post, you would need a
> > Java-based XSLT 2.0 processor (such as Michael Kay's 'Saxon').
> >
> > Tony Graham.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:fo="
http://www.w3.org/1999/XSL/Format"
xmlns:file="java.io.File"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:variable name="image-url" select="'logo.jpg'"/>
<!-- <xsl:variable name="image-url" select="'file:///D:/Temp/_XslFo/FileExtension/logo.jpg'"/> -->
<!-- <xsl:variable name="image-url" select="'
http://www.renderx.com/Images/logo.gif'"/> -->
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master margin-right="2.5cm" margin-left="2.5cm" margin-bottom="2cm" margin-top="1cm" page-width="21cm" page-height="29.7cm" master-name="first">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="first">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:variable name="exists">
<xsl:call-template name="file.check">
<xsl:with-param name="filename" select="$image-url"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$exists=true()">
<fo:external-graphic src="url({$image-url})"/>
</xsl:when>
<xsl:otherwise>NO IMAGE EXIST!</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template name="file.check">
<xsl:param name="filename" />
<xsl:choose>
<xsl:when test="function-available('file:new')">
<xsl:variable name="fileobj"
select="file:new($filename)" />
<xsl:choose>
<xsl:when test="not(file:exists($fileobj))">
<xsl:value-of select="true()"/>
<xsl:message>
<xsl:text>File name='</xsl:text>
<xsl:value-of select="$filename" />
<xsl:text>' exists.</xsl:text>
</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
<xsl:message>
<xsl:text>File name='</xsl:text>
<xsl:value-of select="$filename" />
<xsl:text>' does not exist.</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>WARNING : unable to call function 'file:new'</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>