On 29 Jan 2004 23:08:15 GMT,
ri*****@cogsci.ed.ac.uk (Richard Tobin) wrote:
Annoying, isn't it :-)
You could use a string of all the (necessary) characters as Michael
suggests, or you could do something like:
That won't work since I do not know what range the character code will be in,
and since it's Unicode....building the lookup table would be huge!
<xsl:text disable-output-escaping="yes">&#</xsl:text>
<xsl:value-of select="$number"/>
<xsl:text>;</xsl:text>
which is, of course, an even grosser hack, but has the advantage of
This doesn't work either, since I'm in a Cocoon pipeline which is just
propagating SAX events. The XML is never written out! What your suggestion
will do (I tried it before I posted my initial request) is write "ʞ" into
the SAX stream, which will NOT work for my needs, since I actually need the
single character written out.
That being said, I did find a quick/elegant solution when using Xalan. I used a
Xalan extension to enable me to call a core Java class to do the code to
character conversion for me. The callable template (charUtilities.xsl) looks
somewhat like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:char="http://xxx.com/char"
xmlns:charUtil="http://xxx.com/charUtil"
extension-element-prefixes="char charUtil">
<xalan:component prefix="charUtil">
<xalan:script lang="javaclass" src="xalan://java.lang.Character"/>
</xalan:component>
<xsl:template name="char:convertNumber">
<xsl:param name="number" select="'160'" />
<xsl:value-of select="charUtil:new( number( $number ) )"/>
</xsl:template>
</xsl:stylesheet>
To then use the conversion template you do something like the following:
<xsl:import href="charUtilities.xsl" />
......
<xsl:call-template name="char:convertNumber">
<xsl:with-param name="number" select="670"/>
</xsl:call-template>
The only real downside with this approach is that you end up tied to Xalan,
which in my case is not a big deal.
.....Andrzej
NOTE: Remove Spamicide(tm) before replying!!!