xsl-list
[Top] [All Lists]

[xsl] Replacing the space character with another character

2007-05-13 08:17:14
Hi,

I'm trying to replace the space character with another character (I've
chosen the asterisk, but it could be anything) in a specific element's text
contents. I've read the Replace and String Replace pages on Dave Pawson's
site, and have read about the translate XPath function, but am still coming
up empty (literally!).


In my input XML, I have a number of <indexterm> elements such as the
following:

 <indexterm>Greek History</indexterm>


I'd like to replace the space character as follows:

  <indexterm>Greek*History</indexterm>


My stylesheet contains the following template:

 <xsl:template match="indexterm">
     <indexterm>
        <xsl:value-of select="translate(.,'&#x20;','&#x26;')"/>
     </indexterm>
 </xsl:template>


For some reason, the stylesheet removes the spaces, rather than replacing
them with the asterisk:

 <indexterm>GreekHistory</indexterm>


What am I doing wrong?

Thanks,
Mark


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

<Prev in Thread] Current Thread [Next in Thread>