Written by

Question Con Skordis · Jan 26, 2022

Using XSLT to add background image

I have a PDF ZEN report module that I'm using XslFoXslt to highlight the table cell.

What I need is for a particular value to add a background image to the <item> that is calling the XSLFoXslt

The code I have is the following but all that happens is the color. 

XData XslFoXslt
{
<xsl:template name="HighLight">
<xsl:param name="Value"/>

<xsl:if test="$Value = 400">
<xsl:attribute name='background-image'>url("images/trash-icon.png")</xsl:attribute>
<xsl:attribute name='background-repeat'>no-repeat</xsl:attribute>
<xsl:attribute name='color'>#ffffff</xsl:attribute></xsl:if>

</xsl:template>
}
 

Product version: Caché 2018.1

Comments

George James · Jan 26, 2022

Hi Con

I think your problem might be that background-image and background-repeat are CSS properties, not HTML attributes.  Color works because it is an HTML attribute (although you should use the CSS style property for this as well these days).

Try:

<xsl:if test="$Value = 400">
     <xsl:attribute name='style'>background-image: url("images/trash-icon.png"); background-repeat: no-repeat;</xsl:attribute>
     <xsl:attribute name='color'>#ffffff</xsl:attribute>
</xsl:if>

If that works then you might want to consider using a class attribute to reference a stylesheet rather than including a style attribute directly, but that's another matter.

George

0
Con Skordis  Jan 26, 2022 to George James

Thanks George but unfortunately the pdf fails to render.

0
George James  Jan 26, 2022 to Con Skordis

Hi Con

Check the url reference to the image.

George

0
George James  Jan 26, 2022 to George James

Hi Con

Actually, xsl-fo has it's own way of styling so what I suggested, which would work for html, probably isn't applicable for xsl-fo.

George

0
Con Skordis  Jan 26, 2022 to George James

Thank you for your time on this.

0
Con Skordis  Jan 26, 2022 to George James

George,

With reference the PDF errors and does not appear at all.

Con

0
Con Skordis · Jan 26, 2022

If there is no way to add image to the XSLT template, is it possible to add &#8593; for up arrow?

0