Reputation: 57
I have a sniplet in my xslt like:
<fo:block>
<fo:external-graphic src="data:image/png;base64, //base64 code//" />
</fo:block>
Not to clutter my main stylesheet, i have created another xslt that have the base64 image as parameter like:
<xsl:param name="logo">data:image/png;base64, //base64 code//</xsl:param>
If i change my main stylesheet to:
.
.
<xsl:include href="image.xsl" />
.
.
<fo:block>
<fo:external-graphic>
<xsl:attribute name="src"><xsl:value-of select="$logo" /></xsl:attribute>
</fo:external-graphic>
</fo:block>
1st i get a heap-size error and after using -Xmx4096m i get a parse error.. When i have the base64 image embedded in the main stylesheet, i don't need the 4gb heap and the pdf i make have the image as intented.
Using Apache FOP 1.1 and sorry for my english, not my main language..
Upvotes: 2
Views: 11572
Reputation: 22647
You are trying to use an attribute value template, I think. Use {
and }
to indicate that $logo
is not a literal value, but a variable or parameter.
<fo:external-graphic src="{$logo}" />
Like this it is even more concise, since you do not have to type xsl:value-of
.
Otherwise, $logo
is stored as literal text content. Read about attribute value templates here.
To illustrate this:
Stylesheet
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:param name="logo">data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QNaRXhpZgAATU0AKgAAAAgADQEPAAIAAAAGAAAAqgEQ</xsl:param>
<fo:external-graphic src="{$logo}"/>
</xsl:template>
</xsl:stylesheet>
Output
<?xml version="1.0" encoding="utf-8"?>
<fo:external-graphic xmlns:fo="http://www.w3.org/1999/XSL/Format" src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QNaRXhpZgAATU0AKgAAAAgADQEPAAIAAAAGAAAAqgEQ"/>
Upvotes: 6