Changeset 618 for MDRepository
- Timestamp:
- 08/11/10 14:45:50 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MDRepository/trunk/xquery/cmd-model.xqm
r570 r618 78 78 Recurse for collections 79 79 :) 80 declare function cmd-model:recurse-collections($collection as xs:string, $depth as xs:integer) as item()* {81 let $children := xdb:get-child-collections($collection)80 declare function cmd-model:recurse-collections($collection as node()+, $parent as xs:string, $depth as xs:integer) as item()* { 81 let $children := if ($depth eq 0) then () else $collection//ResourceProxy[ResourceType = "Metadata"] 82 82 return 83 83 if (fn:exists($children)) then 84 84 let $child-results := 85 85 for $child in $children 86 return 87 cmd-model:recurse-collections(concat($collection, '/', xs:string($child)), $depth), 88 $current := <Collection name="{text:groups($collection, "/([^/]+)$")[last()]}">{$collection}</Collection> 89 return ($current, $child-results) 86 let $child-doc := doc(concat(util:collection-name($child/root()), "/", $child/ResourceRef)), 87 $child-name := ($child-doc//Corpus/Name, "UNKNOWN")[1] 88 return if (empty($child-doc)) then <no-target>{util:collection-name($child/root())}</no-target> else 89 cmd-model:recurse-collections($child-doc, $child-name, $depth - 1) 90 return 91 <c n="{$parent}" cnt="{sum($child-results/@cnt)}">{$child-results}</c> 90 92 else 91 < Collection>{$collection}</Collection>93 <c n="{$parent}" cnt="{count($collection//CMD)}"></c> 92 94 }; 93 95 … … 258 260 else 259 261 let $children := for $collection-item in $collections 260 return 261 cmd-model:recurse-collections($collection-item, $max-depth) 262 let $collection-item-doc := collection(concat($collection-item, "/", "Corpusstructure")) 263 return 264 cmd-model:recurse-collections($collection-item-doc, "", $max-depth) 262 265 return 263 266 cmd-model:store-collection-data(<Collections count="{count($children)}" root="{$collections}">{$children}</Collections>, $names[1], $names[2])
Note: See TracChangeset
for help on using the changeset viewer.