[xsl] String manipulation XSLT 1.0

Subject: [xsl] String manipulation XSLT 1.0
From: pankaj.c@xxxxxxxxxxxxxxxxxx
Date: Wed, 22 Sep 2010 18:14:54 +0530
Hello everybody,

I have an element,

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.

Concat also does not seems to be fit here

    <xsl:value-of select="concat(translate(.,'.','.'), ' ')"/> 

I can do the string-length() sort of thing to add "space" after each dot, 
but that would look ugly and moreover input can have 3-4 initials in it.

Is there a better way of getting this done?

Too bad I am working in XSLT 1.0 otherwise replace() would have fit the 
bill or for that matter simple regular expression would have been suffice. 


TIA,
Pankaj 

Current Thread