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]
^
in
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">
<idno>001</idno>
</body>
<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<idno>051</idno>
</body>
<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<idno>101</idno>
</body>
________________________________________________________________________
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:
http://www.star.net.uk
________________________________________________________________________