xsl-list
[Top] [All Lists]

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

2007-11-26 13:03:56
Nothing wrong with it, but it doesn't meet the stated requirement, that is, it isn't part of XSLT 1.0. --
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Steven Ericsson-Zenith <steven(_at_)semeiosis(_dot_)org>
Sent:     Mon, 26 Nov 2007 11:47:45 -0800
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  Re: [xsl] Converting a string to Uppercase or Lowercase  without 
using translate() ?


Mmmm. Forgive me but what is wrong with fn:upper-case?

Sincerely,
Steven

--
Dr. Steven Ericsson-Zenith
Institute for Advanced Science & Engineering
http://iase.info
http://senses.info


On Nov 26, 2007, at 11:28 AM, G. Ken Holman wrote:

At 2007-11-26 18:59 +0000, Gareth Howells wrote:
I'm trying to convert a string to uppercase before using it in a select statement using XSLT 1.0, and for now I'm using translate() as follows:

<xsl:variable name="pClubCaps" select="translate($pClub,
'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSSTUVWXYZ')" />

where $pClub is a parameter passed to the stylesheet from a JSP page. Of course, converting to lowercase would simply require the second and third
parameters of translate() to be switched.

I was wondering if there's a nicer way of converting strings to upper or
lower case, rather than using translate()?

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'>
 <!ENTITY upper 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'>
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
               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.

I hope this helps.

. . . . . . . . . . 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(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--






--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
  • RE: Re: [xsl] Converting a string to Uppercase or Lowercase without using translate() ?, cknell <=