Re: variable binding in XPath was: Comments on XPath (30th April)

Mike wrote:
> Yes. The strongest use case for adding LET is that it would allow
> you to bind to the context node at each level of predicate nesting:
>
>    chapter[let $c := @id return section [starts-with(@id,$c)]]

Yes, that's very very useful. I agree with David -- adding let would
allow you to get rid of specialised range variables and provide useful
functionality on the XPath side without forcing people to write
user-defined functions to achieve their goals. It's essential if you
don't allow sequence generation with XSLT, and I think it makes a good
balance in either case.

> I don't like the syntax: it would be much nicer to write
>
>    chapter[$c; section [starts-with(@id,$c/@id)]]
>
> but at least it gives the functionality.

I like the shorter syntax (assuming that it would support assignment
to any expression, not just the context node (though the shorthand for
the context node would be lovely)). Like David, I would favour an
symbolic infix operator for the foreach expression too (e.g. '=>' or
'->') because of the parallel with the '/' operator. But with the
amount of code we're looking at being tucked up in an XPath, keywords
definitely make things a lot clearer.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 23 May 2002 11:50:43 UTC