|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Using Sum and CountWei, Alice J. ajwei at indiana.eduTue Jan 15 18:33:21 PST 2008
Hi, Thanks for the replies. Returning to your question, what I want is something simple. That is, to compute how many "nodes" there are in the XML to express how many child occurrences are from the parent. The result I have computed before your configurations show individual numbers of the occurrences of the nodes, which is "1". Instead of seeing "1" line after line, I only want to see one line that tells me how many occurrences are there from the XML without printing the rest of the stuff in the code. Is this possible? Thanks to those who can help. ====================================================== Alice Wei MIS 2008 School of Library and Information Science Indiana University Bloomington http://x-query.com/mailman/listinfo/talk ________________________________________ From: David Carlisle [http://x-query.com/mailman/listinfo/talk] Sent: Tuesday, January 15, 2008 6:25 PM To: Wei, Alice J. Cc: http://x-query.com/mailman/listinfo/talk Subject: Re: Using Sum and Count 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. ________________________________________________________________________
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






