xsl-list
[Top] [All Lists]

Re: [xsl] String manipulation XSLT 1.0

2010-09-22 07:50:27
pankaj(_dot_)c(_at_)thomsondigital(_dot_)com wrote:

Input
====
<given-name>A.H.</given-name>

Output
====
<given-name>A. H.</given-name> <!--  Notice the space after A.  -->

I tried using translate function

<xsl:template match="given-name">
<xsl:copy>
<xsl:value-of select="translate(.,'.','. ')"/> </xsl:copy> </xsl:template>

But noticed that translate ignores space given to second argument after dot (single character to single character). So the result is same as it is.

translate translates character by character. Maybe
<xsl:value-of select="concat(substring-before(., '.'), '. ', substring-after(., '.'))"/> does what you want but it depends on what kind of contents that given-name element can contain.
Or check http://exslt.org/ for a replace template for XSLT 1.0.



--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
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>
--~--