xsl-list
[Top] [All Lists]

Re: Character substitution

2005-01-10 02:53:24
Why should it be iso-8859-1, there is no € symbol specified, first in 
iso-8859-15?
The euro symbol is represented how you can see it in my xml file.

Jim Fuller wrote:

Sven Waibel wrote:

Hello,

i looked at the FAQ and i found the solution to replace characters.
But the variable text is empty resp. match="text()"
and then the . returns nothing.
How can i substitute the € character?


how is the euro character represented in your document ?

is it an entity (e.g. I think its numeric entity is &128;) if so u might
have to;

- try using numeric entity for replacement
- make sure your xml encoding is iso-8859-1 (or UTF-8)

you can take a look at an xsl template that has been tested over time at
 exslt.org
http://www.exslt.org/str/functions/replace/index.html

gl, Jim Fuller

my xsl:
--------------------------------------------------------------
<xsl:template match="text()">
   <xsl:call-template name="change" >
    <xsl:with-param name="text" select="."/>
   </xsl:call-template>
</xsl:template>

<xsl:template name="change">
   <xsl:param name="text"/>
    <xsl:value-of select="$text"/>
    <xsl:choose>
        <xsl:when test="contains($text, '€')">
            <xsl:value-of select="substring-before($text, '€')"/>
                  &#8364;
               <xsl:call-template name="change">
                <xsl:with-param name="text"
select="substring-after($text,'€')"/>
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$text"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

--------------------------------------------------------------

my xml:
--------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-15"?>
<test>
    <header>
        <creation date="2005-01-10" timestamp="1105349670236"
user="sven" login="sven" />
    </header>
    <test-t id="35" >
    <numbering>1</numbering>
    <name><![CDATA[TT€]]></name>
    <path><![CDATA[/TT€]]></path>
    </test-t>   
</test>
--------------------------------------------------------------

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>