File: rdb-queries-results-q12-static-cbcl.xq

package info (click to toggle)
qtxmlpatterns-opensource-src 5.15.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 308,892 kB
  • sloc: xml: 360,343; cpp: 91,994; ansic: 388; sh: 53; sed: 31; makefile: 23
file content (34 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(: insert-start :)
declare construction strip;
declare variable $input-context1 external;
declare variable $input-context2 external;
(: insert-end :)

declare function local:bid_summary()
  as element()*
{
    for $i in distinct-values($input-context2//itemno)
    let $b := $input-context2//bid_tuple[itemno = $i]
    return
        <bid_count>
            <itemno>{ $i }</itemno>
            <nbids>{ count($b) }</nbids>
        </bid_count>
};

<result>
 {
    let $bid_counts := local:bid_summary(),
        $maxbids := max($bid_counts/nbids),
        $maxitemnos := $bid_counts[nbids = $maxbids]
    for $item in $input-context1//item_tuple,
            $bc in $bid_counts
    where $bc/nbids =  $maxbids and $item/itemno = $bc/itemno
    return
        <popular_item>
            { $item/itemno }
            { $item/description }
            <bid_count>{ $bc/nbids/text() }</bid_count>
        </popular_item>
 }
</result>