1.- delete the whie spaces and show:
holasoyyo
This is simple
<xsl:value-of select="translate(root,' ','')"/>
2.- how can i substitute the whiel spaces with %20?
hola%20soy%20yo
To do this you have to write a recursive template that searches and replaces
the string..
Try This
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!-- First One .. Get rid of spaces -->
<xsl:value-of select="translate(root,' ','')"/>
<!-- Second one Replace space with %20 -->
<br/>
<xsl:call-template name="replace">
<xsl:with-param name="text-string" select="root"/>
<xsl:with-param name="find-word" select="' '"/>
<xsl:with-param name="replace-with" select="'%20'"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="replace">
<xsl:param name="text-string"/>
<xsl:param name="find-word"/>
<xsl:param name="replace-with"/>
<xsl:choose>
<xsl:when test="contains($text-string,$find-word)">
<xsl:call-template name="replace">
<xsl:with-param name="text-string"
select="concat(substring-before($text-string,$find-word),$replace-with,subst
ring-after($text-string,$find-word))"/>
<xsl:with-param name="find-word" select="$find-word"/>
<xsl:with-param name="replace-with" select="$replace-with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text-string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The above template ( replace ) is a generic one, and you can use it for any
string replace functionality..
for an xml that looks like
<?xml version="1.0"?>
<root>hola soy yo</root>
The output would be
holasoyyo
hola%20soy%20yo
in a HTML view
Hope This Helps
Vasu
----- Original Message -----
From: "Dionisio Ruiz de Zarate" <dionisio(_at_)tinieblas(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, June 04, 2004 12:04 PM
Subject: [xsl] delete the white spaces
Hello y have one xml with this:
<root>hola soy yo</root>
i make:
<xsl:value-of select="root" disable-output-escaping="yes"/>
but it shows me the white spaces.
how can i:
1.- delete the whie spaces and show:
holasoyyo
2.- how can i substitute the whiel spaces with %20?
hola%20soy%20yo
thanks
--+------------------------------------------------------------------
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>
--+--