xquery新手求教
请问如何使用xquery来统计一个xml文件中<section/>的个数?xquery中是否有跟sql中的groupby类似的语句?
[解决办法]
count($doc//section)
group by
<books>
<book bookid="1">
<title>Java Web Services</title>
<subject>XML</subject>
</book>
<book bookid="2">
<title>XML Applications</title>
<subject>XML</subject>
</book>
<book bookid="4">
<title>Beginning Visual C++ 6 Database Programming</title>
<subject>Database</subject>
</book>
<book bookid="5">
<title>Beginner's Guide to Access 2.0</title>
<subject>Database</subject>
</book>
</books>
<subjects> {
for $subject in distinct-values(/books/book/subject)
let $books-in-group := /books/book[subject=$subject]
return
<subject name="{$subject}"> {
for $book in $books-in-group
return
<book-title>{$book/title/text()}</book-title>
} </subject>
} </subjects>