Changeset 174 for MDService


Ignore:
Timestamp:
02/03/10 23:33:28 (14 years ago)
Author:
ljo
Message:

queryModel() now taking parameters q (eg MDGroup.Actors.Actor), maxdepth (n default 1), path (material name path eg silang_data or olac/OLAC/The_LINGUIST_List_Language_Resources) and format (only default xml)

Location:
MDService/trunk/xquery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • MDService/trunk/xquery/cmd-model.xql

    r139 r174  
    44 $Id$
    55:)
     6import module namespace request="http://exist-db.org/xquery/request";
    67
    78import module namespace cmd-model = "http://spraakbanken.gu.se/clarin/xquery/model"
     
    910
    1011(: cmd-model:recurse-collections-model("/db/cmdi-mirror/olac/OLAC/The_LINGUIST_List_Language_Resources", "//MDGroup/Actors/Actor", 4) :)
    11 cmd-model:get-result-doc("/db/cmdi-mirror/silang_data", "Actor", 4)
     12
     13declare function local:cmd-model() as item()* {
     14  let $action :=  request:get-parameter("operation", ""),
     15    $cmd-index := request:get-parameter("q", "MDGroup/Actors/Actor"),
     16    $cmd-index-path :=
     17    if (fn:contains($cmd-index, ".")) then
     18      fn:translate($cmd-index, ".", "/")
     19    else
     20      $cmd-index,
     21    $format := request:get-parameter("format", "xml"),
     22    $path := fn:concat("/db/cmdi-mirror/", request:get-parameter("path", "silang_data")),
     23    $max-depth as xs:integer := xs:integer(request:get-parameter("maxdepth", 1))
     24
     25    return
     26    cmd-model:get-result-doc($path, $cmd-index-path, $max-depth)
     27};
     28
     29local:cmd-model()
  • MDService/trunk/xquery/cmd-model.xqm

    r125 r174  
    1111declare variable $cmd-model:cmdiMirrorPath as xs:string {"/db/cmdi-mirror"};
    1212
    13 declare variable $cmd-model:typeActorPath as xs:string {"//MDGroup/Actors/Actor"};
     13declare variable $cmd-model:typeActorPath as xs:string {"MDGroup/Actors/Actor"};
     14declare variable $cmd-model:typeActorPath0 as xs:string {"Actor"};
    1415
    1516declare variable $cmd-model:typeActorPathElementPrefix as xs:string {"actor"};
     
    2021
    2122declare function cmd-model:elem($collection as xs:string, $path as xs:string, $depth as xs:integer) as element() {
    22   let $path-nodes := util:eval(fn:concat("collection('", $collection, "')", $path))
     23  let $path-nodes := util:eval(fn:concat("collection('", $collection, "')//", $path))
    2324  let $path-count := count($path-nodes)
    2425   
     
    2829  let $text-count-distinct := count(distinct-values($text-nodes))
    2930  return
    30         <elem path="{$path}" count="{$path-count}" count_text="{$text-count}"  count_distinct_text="{$text-count-distinct}" >
     31        <elem path="{fn:concat("//", $path)}" count="{$path-count}" count_text="{$text-count}"  count_distinct_text="{$text-count-distinct}" >
    3132        { if ($depth > 0) then
    3233            for $elname in $subs[. != '']
     
    8283      cmd-model:create-doc($collection, $type-name, $depth)
    8384    return
    84       fn:doc(fn:concat($collection, "/", $type-name, xs:string($depth), $cmd-model:xmlExt))
     85      fn:doc(fn:concat($collection, "/", $new-name, xs:string($depth), $cmd-model:xmlExt))
    8586};
    8687
     
    163164  if ($type-name eq $cmd-model:typeActorPath) then
    164165    fn:concat($cmd-model:typeActorPathElementPrefix, $cmd-model:docTypeSuffix)
     166  else if ($type-name eq $cmd-model:typeActorPath0) then
     167    fn:concat($cmd-model:typeActorPathElementPrefix, $cmd-model:docTypeSuffix)
    165168  else
    166169    ()
Note: See TracChangeset for help on using the changeset viewer.