Subject: Re: mapping (Was: Re: [xsl] Re: . in for) From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 10 Jan 2002 12:32:16 +0000 |
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 expression. 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() function): sum(item, expression (item * price)) It's a bit sneaky, but it might just work... Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: mapping (Was: Re: [xsl] Re: . i, David Carlisle | Thread | Re: mapping (Was: Re: [xsl] Re: . i, Joerg Pietschmann |
[xsl] Problems to interpret an attr, Roman Huditsch | Date | Re: [xsl] use cases for d-o-e, roger . day |
Month |