[xquery-talk] Using Sum and Count

David Carlisle davidc at nag.co.uk
Tue Jan 15 23:25:13 PST 2008


If I understand your requirement you just want
<statistics>{
count(doc("http://chausie.slis.indiana.edu:8080/exist/rest//db/resume/resume.xml")//projection)
}</statistics>
no need for a FLWR clause here.



for $project in
doc("http://chausie.slis.indiana.edu:8080/exist/rest//db/resume/resume.xml"),

using for over a single node is rather odd in xquery (it means the same
as let, it's needed in Xpath2 which lacks the let clause, but not here)

$head in $project//projection


here again I think you intended let rather than for, using for means
that $head gets bound, on each iteration, to a single projection
element, so count($head) is always going to be 1.

Conversely 
let $head := $project//projection

would bind $head to the sequence of elements so count() would do
something useful.

finally I'm not sure what you intended to sum with sum() but expressions
need to be in {} as otherwise it's just taken as a text node child of
the generated eleemnt.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________


More information about the talk mailing list