Altova Mailing List Archives

Re: [xsl] Spaces to %20

From: pcarey@-----------
Date: 7/6/2007 12:51:00 PM
In XSLT 1, something like this:

<xsl:template name="replace">
 <xsl:param name="string"/>
   <xsl:when test="contains($string, ' ')">
      <xsl:value-of select="substring-before($string,' ')"/>
      <xsl:call-template name="replace">
        <xsl:with-param name="string" select="substring-after($string,'
      <xsl:value-of select="$string"/>

In your case, you'd pass $kw to this template.

Hope this helps,


             Kerry Kobashi                                                 
             .net>                                                      To 
             07/06/2007 02:40                                           cc 
                                       [xsl] Spaces to %20                 
             Please respond to                                             

Hi all,

I need a way to convert all spaces into %20 for the anchor tag href below:

<xsl:for-each select="/article/keywords/keyword">
   <xsl:variable name="kw" select="."/>
     <a href="/search.php?keyword={$kw}" title="{$kw}">
        <xsl:value-of select="$kw" />
   <xsl:if test="position()!=last()">, </xsl:if>

<?xml version="1.0" encoding="UTF-8"?>
       <keyword>Cascading Style Sheet</keyword>
       <keyword>Hypertext Markup Language</keyword>


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.