Changeset 707 for MDRepository


Ignore:
Timestamp:
09/20/10 14:16:59 (14 years ago)
Author:
vronk
Message:

should be able to handle empty collection-param

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MDRepository/trunk/xquery/cmd-model.xqm

    r705 r707  
    3030declare variable $cmd-model:collectionDocName as xs:string := "collection.xml";
    3131
     32declare variable $cmd-model:collectionRoot as xs:string := "root";
     33
    3234declare variable $cmd-model:xmlExt as xs:string := ".xml";
    3335
     
    4143};
    4244
    43 declare function cmd-model:elem-r($collection as xs:string, $path as xs:string, $max-depth as xs:integer, $depth as xs:integer) as element() {
     45declare function cmd-model:elem-r($collection as xs:string+, $path as xs:string, $max-depth as xs:integer, $depth as xs:integer) as element() {
    4446  (: let $path-nodes := util:eval(fn:concat("collection('", $collection, "')//", $path)) :)
    45   let $path-nodes := for $coll in $collection return util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')//CMD[.//IsPartOf='", xdb:decode($coll) ,"']"))
     47        let $path-nodes :=
     48                if ($collection[1]=$cmd-model:collectionRoot) then
     49                                util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')//", $path))
     50                        else
     51                                for $coll in $collection return util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')//CMD[.//IsPartOf='", xdb:decode($coll) ,"']//", $path))
     52
    4653  let $path-count := count($path-nodes)
    4754   
     
    250257
    251258(:
    252   Skapa elementnamn för dokumentet av typ.
     259  Skapa elementnamn för dokumentet av typ.
    253260:)
    254261declare function cmd-model:get-doc-type-element-name($type-name as xs:string) as xs:string {
     
    316323declare function cmd-model:search-retrieve($cql-query as xs:string, $collection as xs:string+, $format as xs:string, $start-item as xs:integer, $end-item as xs:integer) as item()* {
    317324  (:  let $results := for $coll in $collection return util:eval(fn:concat("collection('", xdb:decode($coll), "')", xdb:decode($cql-query), "/ancestor::CMD")), :)
    318         let $results := for $coll in $collection return util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD", "[.//IsPartOf='", xdb:decode($coll) ,"']")),
    319     $result-count := fn:count($results),
     325        let $results :=
     326                if ($collection[1]=$cmd-model:collectionRoot) then
     327                                util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD"))
     328                        else
     329                                for $coll in $collection return util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD", "[.//IsPartOf='", xdb:decode($coll) ,"']"))
     330
     331    let $result-count := fn:count($results),
    320332    $result-seq := fn:subsequence($results, $start-item, $end-item),
    321333    $seq-count := fn:count($result-seq),
Note: See TracChangeset for help on using the changeset viewer.