I'm working on a XSL 1.0 transformation to get HTML visualisation when displaying the XML in Firefox. In my original XML, I have characters like
é è ‘...
I need to convert them into
é, è, ‘...
I have used this template :
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
Calling for each special character (here for example è) :
<xsl:variable name="newtext">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$originaltext" />
<xsl:with-param name="replace" select="'&egrave;'" />
<xsl:with-param name="by" select="'è'" />
</xsl:call-template>
</xsl:variable>
Is there a solution where I can directly replace &
into & for example without the need to call the replacement template for each special character I expect to exist?
Why don't you simply disable the escaping when outputting the text? For example, given an input of:
you can have your stylesheet process this as:
and return:
which a browser should render as:
This seems to work for me in (an old version of) Firefox:
XML
mystyle.xsl
Result (screenshot):
Caveat: I am not a Javascript expert; this is just something I cobbled together on impulse.