[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: XPath's role (Was: Re: Re: . in for)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 7 Jan 2002 23:20:13 GMT
xpath cartesian
> 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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