Hi Reading http://docs.basex.org/wiki/XQuery_3.0
http://docs.basex.org/wiki/XQuery_3.0I found, that third code listing telling
You can see this effect by changing the return statement to: return element {$income} {count($ppl)}
is exactly the same return statement as in first code listing and shall be probably changed into
return element {$income} {$ppl}
I tried to tell that directly on wiki, but I got no permission to do that, so I use this mailing list for it.
Jan PS: I did not test the sample, I only know, it shall differ from the first one and this is my estimation.