Re: [xsl] Unicode character blocks in strings

Subject: Re: [xsl] Unicode character blocks in strings
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 May 2009 09:21:23 -0400
At 2009-05-26 14:07 +0100, tom tom wrote:
I have a string containing a mix of Chinese and
Latin characters, eg *|.Z'J%R+,H1N1,y7PZL.
I wish to return a nodeset containing the following kind of structure:

*|.Z'J%R+, H1N1 ,y7PZL

Where H1N1 falls into the BasicLatin unicode character block and the other two strings can be categorized as CJKUnifiedIdeographs.

Given defines the characters up to the tilde, this can be done with a character range.

Can anyone suggest the cleanest way to do this using XSLT 2?

I like Michael's and David's suggestion better to use Unicde classes, but below is what I threw together quickly.

. . . . . . . . . . Ken

T:\ftemp>type tom.xml
T:\ftemp>call xslt2 tom.xml tom.xsl
<?xml version="1.0"
T:\ftemp>type tom.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:template match="text()" priority="1">
  <xsl:analyze-string select="." regex="[!-~]+">
      <latin><xsl:value-of select="."/></latin>
      <other><xsl:value-of select="."/></other>

<xsl:template match="@*|node()"><!--identity for all other nodes-->
    <xsl:apply-templates select="@*|node()"/>


T:\ftemp>rem Done!

XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08
Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread