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

Re: [xsl] Force the case of a set of strings

Subject: Re: [xsl] Force the case of a set of strings
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Oct 2012 13:25:56 -0400

At 2012-10-29 17:16 +0000, Kerry, Richard wrote:


I have a sequence of strings which are all 'ok' or 'fail' where I want to force the case of all of them.

Actually, it looks like you have a sequence of nodes in $states, not strings.

When I say they are all 'ok' or 'fail' I actually mean they may be 'ok', 'OK', 'Ok', 'Fail', 'fail', 'FAIL' etc.

I use

<xsl:variable name="ok-fails-1" select="$states/normalize-space(column[7])" />

to extract the sequence from my original xml.

If I say

<xsl:variable name="ok-fails-1-lc" select="lower-case( $ok-fails-1 )" />

then I get told that lower-case can only take a string as its parameter, not a sequence.

Can anyone suggest how I might process my sequence to return a sequence but have each entry passed through lower-case.


I remind my students in class that the "/" in "$nodes/expr" is an abbreviation for:

for $n in $nodes return expr($n)

... which is exactly what you did in setting your first variable. I just took it one step further.

I thought maybe I could pass it as a parameter to a moded apply-templates, but then I get warned that select needs a node, not a string, as its @select attribute.

That shouldn't be necessary if the input is as simple as you imply.

Subsequently I do distinct-values on it and the result of that I want only to contain 'ok' or 'fail', with no case variations remaining.

The sequence above would be satisfactory input to distinct-values().

I hope this helps.

. . . . . . . . . Ken

Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread