xsl-list
[Top] [All Lists]

Re: xslt replace special characters

2002-11-08 13:42:40
Thank you sooo much!!!!.  it works perfectly! :)


From: Greg Faron <gfaron(_at_)integretechpub(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] xslt replace special characters
Date: Fri, 08 Nov 2002 13:33:19 -0700

At 01:14 PM 11/8/2002, you wrote:
thank you. it works if i just use it for one character. can i put in more than one character in the pattern variable at once? if i keep calling the template, obviously i will get the string variable the number of i call the template. so what do you suggest that i do if i have a string like this.
http://www.domain.com?xxx=yyy&www=y
i want to convert

? to %3f
= to %3d
& to %26

You must call the template multiple times, each time feeding it the result of the previous replacement. The following command
    <xsl:call-template name="replace">
      <xsl:with-param name="string">
        <xsl:call-template name="replace">
          <xsl:with-param name="string">
            <xsl:call-template name="replace">
              <xsl:with-param name="string" select="$url"/>
              <xsl:with-param name="pattern" select="'&amp;'"/>
              <xsl:with-param name="replacement" select="'%26'"/>
            </xsl:call-template>
          </xsl:with-param>
          <xsl:with-param name="pattern" select="'='"/>
          <xsl:with-param name="replacement" select="'%3d'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="pattern" select="'?'"/>
      <xsl:with-param name="replacement" select="'%3f'"/>
    </xsl:call-template>
transforms
http://www.domain.com?xxx=yyy&www=y
into
http://www.domain.com%3fxxx%3dyyy%26www%3dy
if the former was located in the variable $url.


Greg Faron
Integre Technical Publishing Co.



XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


..........................................................
Email: arisuu(_at_)hotmail(_dot_)com
Cell: (650) 483-8164
Work: (212) 201-0881
..........................................................

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list