Reputation: 590
I have xml files that will supply the name of a file for an image.
<task>
<header>Diagram</header>
<image>image.png</image>
</task>
In the xls-fo I am trying to use:
<xsl:template match="image">
<fo:block>
<fo:external-graphic>
<xsl:attribute name="src">./<xsl:value-of select="image"/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</xsl:template>
This does not create an error but the image does not appear in the pdf. In order to get the image to appear I have to hard code the name of the file like this:
<xsl:attribute name="src">./image.png<xsl:value-of select="image"/></xsl:attribute>
How do I get the name of the file from the xml to work with the path provided in the xsl.
Upvotes: 0
Views: 3166
Reputation: 23627
You template is already matching image
. Inside it you are in the context of that element, which has no image
child, but just the text node you want to select. When you use <xsl:value-of select="image"/>
inside it, you are actually trying something like task/image/image
.
Replace image
in your value-of
with .
(the string value of the node) or text()
(its text contents). Any option will have the same result.
<xsl:template match="image">
<fo:block>
<fo:external-graphic>
<xsl:attribute name="src">./<xsl:value-of select="."/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</xsl:template>
Upvotes: 1