Re: [xsl] Converting a string to Uppercase or Lowercase without using translate() ?

Subject: Re: [xsl] Converting a string to Uppercase or Lowercase without using translate() ?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2007 09:03:20 -0500
At 2007-11-27 10:32 +0000, Andrew Welch wrote:
On 26/11/2007, G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> If by "nicer" you'll accept "more compact", this is what I direct my
> students to include at the top of their stylesheets:
> <!DOCTYPE xsl:stylesheet [
> <!ENTITY lower 'abcdefghijklmnopqrstuvwxyz'>
> ]>
> <xsl:stylesheet xmlns:xsl="";
> version="1.0">
> Then, in your stylesheet you would have:
> <xsl:variable name="pClubCaps"
> select="translate($pClub,'&lower;','&upper;')"/>
> But as for functionality, translate() is all we have to work with in XSLT 1.0.

Hi Ken,

Out of interest - why in this case would you prefer using entities
over variables?  My advice would be to avoid entities, I don't see any
benefit here (or in most cases, so I'm approaching this from an
already negative angle :) ....  especially for people new to XSLT.

I suppose ... I guess I see the problem as a lexical issue and not an algorithmic issue. I cannot comment on optimization opportunities for XSLT engines when faced with an explicit string or a variable reference ... perhaps someone on the list can comment on this.

Would you tackle the following with a variable as well?

<!DOCTYPE xsl:stylesheet [
   <!ENTITY nbsp '&#xa0;'>
<xsl:stylesheet xmlns:xsl="";

. . . . . &nbsp; . . . . .

I don't think people new to XSLT should forget that we are, after all, working with XML files.

. . . . . . . . . . Ken

-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Nov'07 Legal business disclaimers:

Current Thread