[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: transform each character of a string


Subject: Re: transform each character of a string
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 31 Jan 2000 10:27:27 GMT


  Examples :
  1 is &acirc;
  2 is &ecirc;
  3 is &icirc;
  and so on.

where are those entities defined. If acitc is what I think it is then
that is a unicode letter so that one could be done with
translate(.,`1`,'&#xE5;')
the other ones if they are ring-accent on letters are not single unicode
characters so you can't use translate, but you could use this:


<!-- replace all occurences of the character(s) `from'
     by the string `to' in the string `string'.-->
<xsl:template name="string-replace" >
  <xsl:param name="string"/>
  <xsl:param name="from"/>
  <xsl:param name="to"/>
  <xsl:choose>
    <xsl:when test="contains($string,$from)">
      <xsl:value-of select="substring-before($string,$from)"/>
      <xsl:value-of select="$to"/>
      <xsl:call-template name="string-replace">
      <xsl:with-param name="string" select="substring-after($string,$from)"/>
      <xsl:with-param name="from" select="$from"/>
      <xsl:with-param name="to" select="$to"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


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



Current Thread
Keywords