Re: [xsl] XSL Remove part of a text inside TAG

Subject: Re: [xsl] XSL Remove part of a text inside TAG
From: "Reinier Sta. Teresa" <reinier.stateresa@xxxxxxxxxxxx>
Date: Fri, 07 Mar 2008 11:07:15 +0800
Hi Buddhi,
Actually I want ONLY to remove a path from this tag,

<FontFace>D:\Work\Phase III\Executables\Fonts\TIMESNRO.FNT</FontFace>

In final xml file I want to appear it as this,


For XSL 1.0 you could use recursive call:

<xsl:template match="FontFace">
<xsl:copy> <xsl:call-template name="getBaseName">
<xsl:with-param name="filename" select="."/>
<xsl:template name="getBaseName">
<xsl:param name="filename" />
<xsl:if test="not(contains($filename,'\'))">
<xsl:value-of select="$filename"/>
<xsl:if test="contains($filename,'\')"> <xsl:call-template name="getBaseName">
<xsl:with-param name="filename" select="substring-after($filename,'\')"/>
</xsl:call-template> </xsl:if>

Alternatively for xsl 2.0

<xsl:template match="FontFace">
<xsl:value-of select="tokenize(.,'\\')[count(tokenize(current(),'\\'))]"></xsl:value-of>


Current Thread