source: MDService/trunk/xquery/model_stats.xql @ 124

Last change on this file since 124 was 124, checked in by ljo, 14 years ago

[ignore] adding paths for MDService.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1declare namespace m = "http://www.vronk.net/metares";
2
3(:
4 $Id: model_stats.xql 124 2010-01-12 10:01:18Z ljo $
5:)
6
7import module namespace cmd-model = "http://spraakbanken.gu.se/clarin/xquery/model"
8at "xmldb:exist:///db/clarin/cmd-model.xqm";
9
10declare function m:elem($collection as xs:string, $path as xs:string, $depth as xs:integer) as element() {
11  let $path-nodes := util:eval(fn:concat("collection('", $collection, "')", $path))
12  let $path-count := count($path-nodes)
13   
14  let $subs := distinct-values($path-nodes/child::element()/name())
15  let $text-nodes := $path-nodes//text()
16  let $text-count := count($text-nodes)
17  let $text-count-distinct := count(distinct-values($text-nodes))
18  return 
19        <elem path="{$path}" count="{$path-count}" count_text="{$text-count}"  count_distinct_text="{$text-count-distinct}" >
20        { if ($depth > 0) then
21            for $elname in $subs[. != '']
22            return
23              m:elem($collection, concat($path, '/', $elname), $depth - 1)
24          else 'maxdepth'
25        }</elem>
26};
27
28declare function m:paths($n) {
29        for $el in $n
30        return <elem name="{$el/name()}" > {
31        for $anc in $el/parent::element()
32        return util:node-xpath($anc)
33        }</elem>
34};
35
36
37cmd-model:recurse-collections-model("/db/cmdi-mirror/olac/OLAC/The_LINGUIST_List_Language_Resources", "//MDGroup/Actors/Actor", 4)
38(: cmd-model:get-result-doc("/db/cmdi-mirror/silang_data", "Actor", 4) :)
39(: cmd-model:recurse-collections-model("/db/cmdi-mirror", "//MDGroup/Actors/Actor", 4) :)
40(: m:elem("/db/cmdi-mirror/donated_corpora", '//MDGroup/Actors/Actor', 4) :)
41(: m:paths(//Name) :)
Note: See TracBrowser for help on using the repository browser.