Oxygen XML Editor
 
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XSLT 2.0 Matching characters above 255


Subject: RE: [xsl] XSLT 2.0 Matching characters above 255
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Tue, 1 Mar 2005 15:13:21 -0000

For something I thought not possible - 2 answers :)

I'm guessing the string-to-codepoints() would be much faster, so I'll
use that.

For the archive (and maybe the FAQ DaveP?):

string-to-codepoints():

<xsl:template match="text()">
  <xsl:for-each select="string-to-codepoints(.)">
    <xsl:choose>
      <xsl:when test=". > 255">
 	  <span style="font-family:Code2000">
          <xsl:value-of select="codepoints-to-string(.)"/>
        </span>
	</xsl:when>
	<xsl:otherwise>
	  <xsl:value-of select="codepoints-to-string(.)"/>
	</xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
</xsl:template>

analyze-string:

<xsl:template match="text()">
  <xsl:analyze-string select="." regex="[&#xFF;-&#x10FFFF;]+">
    <xsl:matching-substring>
      <span style="font-family:Code2000">
	  <xsl:value-of select="."/>
      </span>
    </xsl:matching-substring>
    <xsl:non-matching-substring>
      <xsl:value-of select="."/>
    </xsl:non-matching-substring>
  </xsl:analyze-string>
</xsl:template>


Thanks David and Mike,
andrew


Current Thread
 
© 2002-2008 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy
This website was created & generated with <oXygen/> XML Editor