Subject: Re: [xsl] character map "range" in XSLT From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 12 May 2010 14:18:20 -0400 |
I'm writing a XSLT that has to translate XML to plain ascii text. The XML contains unicode characters, possibly any of them. I cannot control the authoring so I must handle whatever is thrown at me.
I have a few dozen specially know character translations for things like 1/4 and degrees unicode symbols.
But I have a need to "catch all" charactors that are not mapped explicitly (rather then map explicitly the entiure unicode set) and translate them into something like "<UNKNOWN CHARACTER>"
Any suggestions on how to do this ? I could trivially write a post-processor to do this (maybe a dozen lines of C or java) but if there's a feature directly in XSLT I'd love to try that.
Any ideas welcome !
<xsl:template match="text()"> <xsl:for-each select="string-to-codepoints(.)"> <xsl:value-of select="if ( . ge 32 and . le 127 ) then codepoints-to-string(.) else concat('<UNKNOWN CHARACTER-',.,'>')"/> </xsl:for-each> </xsl:template>
http://www.iso.org/iso/catalogue_detail.htm?csnumber=51085 http://www.asahi-net.or.jp/~eb2m-mrt/crepdl/ns/structure/1.0/index.xml http://www.assembla.com/spaces/CrepdlValidatorInFsharp
-- XSLT/XQuery training: after http://XMLPrague.cz 2011-03-28/04-01 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] character map "range" in XSLT, David | Thread | Re: [xsl] character map "range" in , steve.majewski@xxxxx |
RE: [xsl] First public working draf, Michael Kay | Date | Re: [xsl] character map "range" in , steve.majewski@xxxxx |
Month |