Changeset 626 for MDRepository
- Timestamp:
- 08/16/10 16:20:54 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MDRepository/trunk/xquery/cmd-model.xqm
r619 r626 78 78 Recurse for collections 79 79 :) 80 declare function cmd-model:recurse-collections($collection as node()+, $parent as xs:string, $ depth as xs:integer) as item()* {80 declare function cmd-model:recurse-collections($collection as node()+, $parent as xs:string, $handle as xs:string, $proxy-id as xs:string, $depth as xs:integer) as item()* { 81 81 let $children := if ($depth eq 0) then () else $collection//ResourceProxy[ResourceType = "Metadata"] 82 82 return … … 85 85 for $child in $children 86 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> else89 cmd-model:recurse-collections($child-doc, $child-name, $ depth - 1)87 $child-name := ($child-doc//Corpus/Name, $child-doc//Session/Name, "UNKNOWN")[1] 88 return if (empty($child-doc)) then <no-target proxy-id="{$child/@id}">{<proxy>{$child}</proxy>, <in-document>{concat(util:collection-name($child/root()), "/", util:document-name($child/root()))}</in-document>}</no-target> else 89 cmd-model:recurse-collections($child-doc, $child-name, $child-doc//Header/MdSelfLink, $child/@id, $depth - 1) 90 90 return 91 <c n="{$parent}" cnt="{sum($child-results/@cnt)}">{$child-results}</c>91 <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{sum($child-results/*:c/@cnt)}">{$child-results}</c> 92 92 else 93 <c n="{$parent}" cnt="{count(collection(concat(util:collection-name($collection/CMD[1]/root()), "/../"))//CMD)}"></c>93 <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{count(collection(concat(util:collection-name($collection/CMD[1]/root()), "/../"))//CMD[not(//ResourceType[. = "Metadata"])])}"></c> 94 94 }; 95 95 … … 260 260 else 261 261 let $children := for $collection-item in $collections 262 let $collection-item-doc := collection(concat($collection-item, "/", "Corpusstructure"))262 let $collection-item-docs := collection(concat($collection-item, "/", "Corpusstructure")) 263 263 return 264 cmd-model:recurse-collections($collection-item-doc, "", $max-depth) 264 for $collection-doc in $collection-item-docs//CMD return 265 cmd-model:recurse-collections($collection-doc, ($collection-doc//Corpus/Name, $collection-doc//Session/Name, "UNKNOWN")[1], $collection-doc//MdSelfLink, "", $max-depth) 265 266 return 266 cmd-model:store-collection-data(<Collections count="{count($children )}" root="{$collections}">{$children}</Collections>, $names[1], $names[2])267 cmd-model:store-collection-data(<Collections count="{count($children/@cnt)}" root="{$collections}">{$children}</Collections>, $names[1], $names[2]) 267 268 return 268 269 cmd-model:serialise-as(cmd-model:get-doc($names[1], $names[2]), $format)
Note: See TracChangeset
for help on using the changeset viewer.