xsl-list
[Top] [All Lists]

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

2008-03-07 09:16:32
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,

<FontFace>TIMESNRO.FNT</FontFace>

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:call-template>
       </xsl:copy>
   </xsl:template>
<xsl:template name="getBaseName">
       <xsl:param name="filename" />
<xsl:if test="not(contains($filename,'\'))">
               <xsl:value-of select="$filename"/>
           </xsl:if>
<xsl:if test="contains($filename,'\')"> <xsl:call-template name="getBaseName"> <xsl:with-param name="filename" select="substring-after($filename,'\')"/> </xsl:call-template> </xsl:if>
   </xsl:template>

Alternatively for xsl 2.0

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

HTH,
Rein


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--