xsl-list
[Top] [All Lists]

RE: XSLT 2.0 Matching characters above 255

2005-03-01 08:13:21

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>