This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: mapping (Was: Re: Re: . in for)
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 8 Jan 2002 19:58:35 +0000
- Subject: Re: mapping (Was: Re: [xsl] Re: . in for)
- Organization: Jeni Tennison Consulting Ltd
- References: <9B66BBD37D5DD411B8CE00508B69700FE7A9C4@pborolocal.rnib.org.uk>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Dave,
>> > This example could be handled with a mapping operator:
>> >
>> > <xsl:variable name="emps"
>> > select="//employee[@dept = ($departments -> lower-case(.))]" />
>
> +1 on mapping, but I dislike the above syntax Jeni.
> Scheme gives (map fn sequence).
>
> How about
>
> select='map lower-case(.) $departments'/>
> or
> select='map (lower-case(.) $departments)'/>
>
> or does this go against the idea of extending keywords?
Well, neither follows the pattern of other operators/keywords in the
XPath 2.0 WD (in particular the second will get confusing because it
looks like a function but without a comma between the arguments) The
closest would be something like:
map lower-case(.) over $departments
but this organisation doesn't make it particularly easy to pipe
functions together (or at least not in a similar way to location
paths). Using the example:
$coordinates -> (. * 2)
-> if (position() mod 2) then . + 50 else .
I think that the above syntax would be:
map (if (position() mod 2) then . + 50 else .) over
map (. * 2) over $departments
Personally, I find that hard to follow, but it may be a factor of what
other languages you're used to.
If you want keywords, we could keep the for expression, just drop the
range variable, so that you had:
for $departments return lower-case(.)
and:
for (for $coordinates return (. * 2))
return if (position() mod 2) then . + 50 else .
Or if you just don't like the -> then there are still a few ASCII
characters left, and several interesting combinations of them, or
there's always a word (or two) as the operator, like 'map':
$departments map lower-case(.)
and:
$coordinates map (. * 2)
map if (position() mod 2) then . + 50 else .
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list