Subject: RE: XSL Remove part of a text inside TAG
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 7 Mar 2008 09:36:31 -0000
|
> 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>
>
In XSLT 2.0
<xsl:template match="FontFace">
<xsl:value-of select="tokenize(., '\\')[last()]"/>
</xsl:template>
In XSLT 1.0 you need to use recursion. You write a recursive named template
that takes the filename as input. If the filename contains "\", then make a
recursive call, supplying substring-after($in, '\') as the parameter value.
If it doesn't contain "\", return the input value as the result.
Michael Kay
http://www.saxonica.com/
|