Page 1 of 1

Problem with adding padding and border to an image

Posted: Fri Feb 07, 2014 4:24 pm
by rww
I'm trying to add padding and a border around images but cannot get my code to work correctly. The code is currently as follows:

Code: Select all

 <xsl:attribute-set name="image">
<xsl:attribute name="border">
<xsl:if test="@outputclass='Border'">
<xsl:attribute name="padding"> 5px </xsl:attribute>
<xsl:attribute name="border"> solid 1pt blue </xsl:attribute>
</xsl:if>
</xsl:attribute>
</xsl:attribute-set>
So, if the outputclass is 'Border' I want an image with 5px padding with a 1pt border. However, the border is coming out as 5px thick. If I move the padding line to after the </xsl:attribute> line the padding and border are drawn correctly, but then all images have padding, which is not what I require.

Can anyone tell me what the problem is and how to fix it?

Thanks

Re: Problem with adding padding and border to an image

Posted: Fri Feb 07, 2014 5:49 pm
by Radu
Hi,

This is for DITA to PDF, right?
You could do something like:

Code: Select all

<xsl:attribute-set name="image">
<xsl:attribute name="border">
<xsl:choose>
<xsl:when test="@outputclass='Border'">
solid 1pt blue
</xsl:when>
<xsl:otherwise>0pt</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="padding">
<xsl:choose>
<xsl:when test="@outputclass='Border'">
5px
</xsl:when>
<xsl:otherwise>0px</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:attribute-set>
In what you tried you nested an xsl:attribute inside another one which is incorrect.

Regards,
Radu

Re: Problem with adding padding and border to an image

Posted: Fri Feb 07, 2014 7:24 pm
by rww
Yes, DITA to PDF. Your code worked beautifully, thanks.