Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Search and replace strings

From: Ralph Wiggum <go.ahead@----.-->
To: NULL
Date: 3/20/2008 11:21:00 PM

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.


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent