[xquery-talk] paging mechanism

David Carlisle davidc at nag.co.uk
Fri Feb 3 11:44:47 PST 2006

  I tried this query:

  for $x at $pos in //text/body/idno
  for $y in $x/body/idno
  order by xs:decimal($x) ascending 
  return $y
  where ($pos mod 50) < 2
  return $x

at each iteration in the above $x is a single idno element
so $y is iterating over $x/body/idno which are idno grandchildren of
these idno elements (which is empty)

  'unexpected token "null" beyond end of query'
Not quite the message I would have expected, but your query ends at the
$y on line 4, you only have one FLWOR expression (which has two for
clauses) so it can only have one "return"

I was going to say what error message saxon gave here, but I see it
gives the "null" message. (Michael?)

If you delete the last two lines you get no error (but no result as $y
is iterating over an empty sequence)

I suggested 

(for $x   idno order by number($x) return $x)[position() mod 50 =1]

But having seen the input form you probably want

(for $x in /col/text/body order by number($x/idno) return $x)[position() mod 50 =1]

$ saxon8q -s col.xml col.xq
<?xml version="1.0" encoding="UTF-8"?>
<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the talk mailing list