This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XPath's role (Was: Re: Re: . in for)



> OK, I'll change the rules. If removing range variables means that to achieve
> simple things, people have to write recursive functions, then I'd rather
> keep range variables!

You could get rid of many uses of range variables if a for loop with
multiple sequences set . to be the sequence representing the current
tuple from the cartesian product that is being iterated over.

Thus where currently you have

for $i in $X, $j in $Y
return
f($i,$j)

you could have

for $X, $Y return f(.[1],.[2])

(the example of return ($i,$j) from the draft would just be return .)

In Jeni's -> notation  (extended, slightly) that would be

[$X,$Y] -> f(.[1],.[2])

using [ , ] -> to denote a map over a cartesian product ([] might not be 
the best possible characters.

However I'm not sure that it helps in enough situations: this would be
like xslt's for-each having an implicit . as the range variable but in
xslt if you have any nested contexts where the current node will change
you can capture the current node of the for-each into a variable
before starting the nested context.

To do that in xpath you'd need to add let expressions, and getting rid
of bound variables in for, only to add let doesn't seem much of a
simplification.  Maybe it is a simplification though, Xpath2 is
currently in the strange situation that it has (like xpath 1) variable
references but it is in the slightly strange position of having compound
expressions that bind variables in addition to having other
functionality (for, some etc) but doesn't have a simple construct (let)
that just does variable binding.

Actually the only difference between for and let appears to be due to
the restriction on having sequences of sequences.
if $x is a sequence, currently ($x) is the same as $x, if instead it was
a singleton sequence with member the original sequence x, then 
let $a := $x ...
would just be
for  $a in ($x) return ...

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]