[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: Thu, 10 Jan 2002 12:32:16 +0000
Re: mapping (Was: Re:  Re: . in for)
Hi Joerg,

> Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> wrote:
>> Function names are indistinguishable from element names,
> [...]
> Well, i realized it somewhat too late as you have seen in my
> follow-up...

Sure :) I'd just sent my message when yours came through.

> This means you want lambda expressions.

Yes please :)

>>  - define a map expression (rather than a map() function)
> Note that in you proposal of a mapping operator
>   $coordinates -> (. * 2)
> the second operand actually *is* already a lambda expression. Hint:
> the . is not bound to the value of the context node as it would
> have been in ordinary expressions.

Yes, I thought so, but I'm not an expert on this functional
programming stuff so I didn't want to claim too much. I think it gives
you lambda expressions in a limited set of circumstances, without
adding lambda expressions as objects in the data model (which I
personally can't see happening in XPath 2.0 - there's just too much
else to sort out).

Now you could see that as a step in the right direction, or you could
see it as potentially undermining future efforts to introduce lambdas
as full objects within XPath/XSLT, because it doesn't introduce a
syntax that discriminates between a lambda expression and a normal

One possibility would be to use a keyword to indicate a lambda
expression, so you'd do:

  LambdaExpr  ::=  "expression" "(" Expr ")"
  MapExpr     ::=  Expr "map" LambdaExpr

and then have:

  $coordinates map expression (. * 2)
               map expression (if (position() mod 2)
                               then . + 50 else .)

We could cover up the fact we were doing this by pretending that the
syntax was simply:

  MapExpr     ::= Expr "map" "expression" "(" Expr ")"

But it would mean that in XPath 3.0 then we could change Expr to
include LambdaExpr. Then you could do (with a properly-defined sum()

  sum(item, expression (item * price))

It's a bit sneaky, but it might just work...



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.