xpathxslt-2.0xslt-3.0

multiple for return in xpath expression


(I'm quite fuzzy on what is XQuery and what is XPath)

I have a scenario where I want to go (in a 'select' attribute in an XSLT 3.0 statement)

for $x in $xs
for $y in $ys
return kooks:foo($x,$y) 

I get (from saxon he)

XPST0003  expected "return", found "for"

So, I can sidestep this by going (and using sequence flattening)...

for $x in $xs
return 
   (for $y in $ys
   return kooks:foo($x,$y))

Is this sensible? is there a more idiomatic way to do this?


Solution

  • I have no problems evaluating e.g.

    let 
      $xs := (1 to 5), 
      $ys := reverse(1 to 5)
    return
      for $x in $xs, $y in $ys
      return sum(($x, $y))
    

    with Saxon HE 12 as XPath 3.1.