RE: Variable references in path expressions

> 
> Correct me if I am wrong, but an expression like
> 
> (1, 2, 3)/(1, 2, 3)
> 
> can as well be written with FLWR expressions:
> 
> for $i in (1, 2, 3) return (1, 2, 3)
> 
> or:
> 
> for $i in (1, 2, 3), $j in (1, 2, 3) return $j
> 
> which is more clear and as powerful.
> 

Yes, it's just a pain having to declare a variable when you don't need one,
and it's stylistically very awkward to use statement introduced by a keyword
nested deeply inside an expression that's otherwise using an infix operator
style. It's very much more convenient to be able to write things like

concat(min(//*/local-name()), '-', max(//*/local-name()))

rather than

concat(min(for $n in //* return local-name($n)), '-', max(for $n in //*
return local-name($n))

As I've said, though, I personally think it's a bit of a compromise and a
dedicated mapping operator would have been better. But compromising is what
committees do...

Michael Kay

 

Received on Thursday, 28 April 2005 08:11:47 UTC