Mercurial > hg > mpdl-group
comparison software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/text/all.xql @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
6:2396a569e446 | 7:5589d865af7a |
---|---|
1 xquery version "1.0"; | |
2 | |
3 module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text"; | |
4 | |
5 declare namespace text = "http://exist-db.org/xquery/text"; | |
6 declare namespace util = "http://exist-db.org/xquery/util"; | |
7 declare namespace local = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/local"; | |
8 | |
9 declare function mpdl-text:indexTerms($document, $indexTermsStartStr, $pn as xs:int, $pageSize as xs:int) as node()* { | |
10 let $index := $document/archimedes/text | |
11 let $language := $document/archimedes/info/lang | |
12 let $from := ($pn * $pageSize) - $pageSize + 1 | |
13 let $to := $pn * $pageSize | |
14 let $maxTo := 10000 | |
15 let $callback := util:function(QName("http://www.mpiwg-berlin.mpg.de/ns/mpdl/local", "local:termEntries"), 2) | |
16 let $indexResult := text:index-terms($index, $indexTermsStartStr, $callback, $maxTo) | |
17 let $count := count($indexResult) | |
18 let $pages := | |
19 if ($count = 0) | |
20 then 0 | |
21 else $count idiv $pageSize + 1 | |
22 let $resultEntries := | |
23 for $entry at $pos in $indexResult | |
24 where $pos >= $from and $pos <= $to | |
25 return $entry | |
26 | |
27 let $result := | |
28 <index-terms> | |
29 <start-string>{$indexTermsStartStr}</start-string> | |
30 <size>{$count}</size> | |
31 <pages>{$pages}</pages> | |
32 <pn>{$pn}</pn> | |
33 {$resultEntries} | |
34 </index-terms> | |
35 return $result | |
36 }; | |
37 | |
38 declare function local:termEntries($term as xs:string, $data as xs:int+) { | |
39 let $result := | |
40 <entry> | |
41 <term>{$term}</term> | |
42 <frequency>{$data[1]}</frequency> | |
43 <documents>{$data[2]}</documents> | |
44 <position>{$data[3]}</position> | |
45 <rank>{$data[4]}</rank> | |
46 </entry> | |
47 return $result | |
48 }; |