I need to add 'px' to font-size values like those in this xml: <style> .class1{ font-family:Arial; font-size:25; } .class2{ font-family:Arial Bold; font-size:20; } </style> So it should be for example font-size:25px; Can someone please give some tips on how to do this with xsl? I have to use MSXML4.
Figured it out by myself: <xsl:template match="style"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:call-template name="stylehead"> <xsl:with-param name="s" select="."/> </xsl:call-template> </xsl:copy> </xsl:template> <xsl:template name="stylehead"> <xsl:param name="s"/> <xsl:choose> <xsl:when test="contains($s, 'font-size:')"> <!--Keep text up to--> <xsl:value-of select="substring-before($s,'font-size:')"/> <xsl:call-template name="styletail"> <xsl:with-param name="s" select="substring-after($s, 'font-size:')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$s"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="styletail"> <xsl:param name="s"/> <xsl:if test="string-length($s)>0"> <!-- keep value, add unit--> <xsl:value-of select="concat('font-size:', substring-before($s,';'), 'px;')"/> <xsl:call-template name="stylehead"> <xsl:with-param name="s" select="substring-after($s, ';')"/> </xsl:call-template> </xsl:if> </xsl:template> Ralph Wiggum wrote: > I need to add 'px' to font-size values like those in this xml: > <style> .class1{ > font-family:Arial; > font-size:25; > } > .class2{ font-family:Arial Bold; > font-size:20; > } > </style> > > So it should be for example font-size:25px; > > Can someone please give some tips on how to do this with xsl? I have to > use MSXML4.