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

Re: Re: . in for

Subject: Re: Re: . in for
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 4 Jan 2002 23:37:02 -0800 (PST)
Re:  Re: . in for
--- Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> wrote:
 
> Sure. The XPath 2.0 WD gives only two distinct examples of the for
> expression, and neither of them would be achievable using the simple
> mapping operator.
> 
> The first one has two range variables, as follows:
> 
>   for $i in (1, 2),
>       $j in (3, 4)
>   return ($i, $j)
> 
> which returns the sequence:
> 
>   (1, 3, 1, 4, 2, 3, 2, 4)
> 
> and is equivalent to:
> 
>   for $i in (1, 2)
>   return for $j in (3, 4)
>          return ($i, $j)
> 
> This iterates over two sequences - (1, 2) and (3, 4) - within the same
> for expression, to create the sequence that contains pairs of possible
> combinations (ish - obviously in flat sequences the 'pairedness' isn't
> explicit).
> 
> The second example has two for expressions. The inner for expression
> creates a sequence to iterate over using the range variable from the
> outer for expression within a predicate:
> 
>   for $a in distinct-values(//author)
>   return ($a,
>           for $b in //book[$b/author = $a]
>           return $b/title)
> 
> I don't think that you can do either of these with the operator syntax
> because you lose track of what *was* the context node as you go from
> one step to the next. If the outer context item was available with the
> current() function, say, then you could do:
> 
>   (1, 2) -> ((3, 4) -> (current(), .))
> 


Maybe something like this:

( (x, y) | x -> (1,2) | y -> (3,4) )



> and:
> 
>   distinct-values(//author) ->
>     (//book[author = current()] -> (current(), title))
> 
> but without range variables, you can't manage these situations.
> 

And:

 ( (y, x ) | x-> //book[author = y]/title | y -> distinct-values(//author) )


Cheers,

Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

 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.