C
clres
Hi,
I have an XSLT that needs to adjust height and width attributes
of images. It sets the width to a particular value and should
adjust the height correspondingly. I cannot seem to get it to
change the height value.
XSLT code snippet:
<xslaram name="maxwidth">220</xslaram>
<xsl:template match="@width">
<xsl:choose>
<xsl:when test="parent::img">
<xsl:attribute name="width"><xsl:value-of
select="$maxwidth"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of
select="round(number(../@height) * ($maxwidth div
number(.)))"/></xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
when working on:
<img width="400" height="100"/>
the result is:
<img width="220" height="100"/>
The height does not change. I cannot seem to alter the height
value when I am at the width attribute node.
How do I do that?
Thanx
Clara
I have an XSLT that needs to adjust height and width attributes
of images. It sets the width to a particular value and should
adjust the height correspondingly. I cannot seem to get it to
change the height value.
XSLT code snippet:
<xslaram name="maxwidth">220</xslaram>
<xsl:template match="@width">
<xsl:choose>
<xsl:when test="parent::img">
<xsl:attribute name="width"><xsl:value-of
select="$maxwidth"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of
select="round(number(../@height) * ($maxwidth div
number(.)))"/></xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
when working on:
<img width="400" height="100"/>
the result is:
<img width="220" height="100"/>
The height does not change. I cannot seem to alter the height
value when I am at the width attribute node.
How do I do that?
Thanx
Clara