[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: mapping (Was: Re: Re: . in for)

Subject: Re: mapping (Was: Re: Re: . in for)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 8 Jan 2002 19:58:35 +0000
Re: mapping (Was: Re:  Re: . in for)
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.