[xsl] how-to change &#*****; to &#****;

Subject: [xsl] how-to change &#*****; to &#****;
From: "Christoph Klocker" <klocker@xxxxxxxxxxxxx>
Date: Tue, 9 Nov 2004 12:23:30 +0100
Hi,

I hope you can help me once again.

I have an ESQL query to our MSSQL database via the JDBC driver, where I
query chinese Unicode characters.
Unfortunately I didn't find an solution to get the unicode characters out of
the database,
so I try a different solution in applying an xsl-transformation and replace
the &amp; with &.
However it doesn't work.

my xml
<categories xmlns:xsp="http://apache.org/xsp";
xmlns:xspdoc="http://apache.org/cocoon/XSPDoc/v1";
	xmlns:esql="http://apache.org/cocoon/SQL/v2";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<category>
		<FaaLocTextCH>&amp;#32173;&amp;#20063;&amp;#32013;</FaaLocTextCH>
	</category>
	<category>
		<FaaLocTextCH>&amp;#27861;&amp;#34349;&amp;#20811;&amp;</FaaLocTextCH>
	</category>
	<category>
		<FaaLocTextCH>&amp;#32016;&amp;#32004; </FaaLocTextCH>
	</category>
	<category>
		<FaaLocTextCH>&amp;#39321;&amp;#28207;</FaaLocTextCH>
	</category>
	<category>
		<FaaLocTextCH>&amp;#38463;&amp;#22982;&amp;#26031;&amp;</FaaLocTextCH>
	</category>
</categories>

and my stylesheet I try to apply

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format";>
	<xsl:template match="/categories/category">
		<xsl:call-template name="escape-apos">
			<xsl:with-param name="text" select="." />
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="escape-apos">
		<xsl:param name="text" />
			<xsl:variable name="apos">&amp;</xsl:variable>
		<xsl:choose>
			<xsl:when test="contains($text, $apos)">
				<xsl:value-of select="substring-before($text, $apos)" />
					<xsl:text disable-output-escaping="yes">&amp;</xsl:text>
				<xsl:call-template name="escape-apos">
					<xsl:with-param name="text" select="substring-after($text, $apos)" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>

thanks for any suggestion
Christoph

Current Thread