using translate()

Discussion in 'XML' started by Xeon, Jul 1, 2003.

  1. Xeon

    Xeon Guest

    Hi,

    I'm trying to replace spaces with %20 with help of translate, but not
    successfull. Here's a node in the xml file :

    <title>This is some test title</title>

    The xsl code I'm using :

    <xsl:value-of select="translate(title, ' ', '%20')"/>

    <xsl:variable name="uri_spacer">%20</xsl:variable>
    <xsl:value-of select="translate(title, ' ', $uri_spacer)"/>

    Both code yields to this result :
    This%is%some%test%title

    The target result :
    This%20is%20some%20test%20title

    Could somebody tell me how can I achieve this?

    TIA
    Xeon, Jul 1, 2003
    #1
    1. Advertising

  2. Using FXSL one writes:


    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:testmap="testmap"
    exclude-result-prefixes="xsl testmap"
    >

    <xsl:import href="str-map.xsl"/>

    <!-- to be applied on any xml source -->

    <testmap:testmap/>

    <xsl:eek:utput omit-xml-declaration="yes" indent="yes"/>

    <xsl:template match="/">
    <xsl:variable name="vTestMap" select="document('')/*/testmap:*[1]"/>
    <xsl:call-template name="str-map">
    <xsl:with-param name="pFun" select="$vTestMap"/>
    <xsl:with-param name="pStr" select="'This is some test'"/>
    </xsl:call-template>
    </xsl:template>

    <xsl:template name="double" match="*[namespace-uri() = 'testmap']">
    <xsl:param name="arg1"/>
    <xsl:choose>
    <xsl:when test="$arg1 = ' '">%20</xsl:when>
    <xsl:eek:therwise>
    <xsl:copy-of select="$arg1"/>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    </xsl:stylesheet>


    The result is:

    This%20is%20some%20test




    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL



    "Xeon" <> wrote in message
    news:...
    > Hi,
    >
    > I'm trying to replace spaces with %20 with help of translate, but not
    > successfull. Here's a node in the xml file :
    >
    > <title>This is some test title</title>
    >
    > The xsl code I'm using :
    >
    > <xsl:value-of select="translate(title, ' ', '%20')"/>
    >
    > <xsl:variable name="uri_spacer">%20</xsl:variable>
    > <xsl:value-of select="translate(title, ' ', $uri_spacer)"/>
    >
    > Both code yields to this result :
    > This%is%some%test%title
    >
    > The target result :
    > This%20is%20some%20test%20title
    >
    > Could somebody tell me how can I achieve this?
    >
    > TIA
    Dimitre Novatchev, Jul 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sridhar Hegde
    Replies:
    2
    Views:
    2,517
    Ajeetha Kumari
    Sep 13, 2004
  2. ***C.Steamer***

    Using the Graphics translate function()

    ***C.Steamer***, Sep 30, 2004, in forum: Java
    Replies:
    1
    Views:
    3,100
    Andrew Thompson
    Sep 30, 2004
  3. Marat
    Replies:
    5
    Views:
    3,772
    John C. Bollinger
    Nov 10, 2004
  4. ak
    Replies:
    8
    Views:
    701
  5. ajcrm125
    Replies:
    3
    Views:
    99
    C.DeRykus
    Sep 20, 2008
Loading...

Share This Page