Changeset 657 for MDRepository
- Timestamp:
- 08/26/10 13:39:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MDRepository/trunk/xquery/cmd-model.xqm
r654 r657 86 86 let $child-doc := if (empty($child/unresolvable-uri)) then doc(concat(util:collection-name($child/root()), "/", $child/ResourceRef)) else (), 87 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 88 return 89 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> :) 90 else 89 91 cmd-model:recurse-collections($child-doc, $child-name, $child-doc//Header/MdSelfLink, $child/@id, $depth - 1) 90 92 return 91 <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{sum($child-results/*:c/@cnt)}" >{$child-results}</c>93 <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{sum($child-results/*:c/@cnt)}" sub-colls="{count($child-results)}" >{$child-results}</c> 92 94 else 93 95 <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> … … 228 230 Get the resource by handle or by path. 229 231 :) 230 declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string) as node() ?{232 declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string) as node()* { 231 233 (: fixme! - urldecode $id when we decide to pass them encoded from the client. :) 232 234 if (starts-with($id, "test-")) then 233 collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = $id]/ancestor::CMD235 collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = xdb:decode($id)]/ancestor::CMD 234 236 else 235 237 collection($id)//IsPartOf[. = "root"]/ancestor::CMD … … 260 262 :) 261 263 declare function cmd-model:get-collections($collections as xs:string+, $format as xs:string, $max-depth as xs:integer) as item() { 262 let $names := if (exists($collections[2])) then 263 ($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($collections, "collection", $max-depth)) 264 else if (starts-with($collections, "test-")) then 265 ($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($collections, "collection", $max-depth)) 266 else 267 ($collections, concat($cmd-model:collectionDocName, xs:string($max-depth))), 268 $dummy := 264 let $names := ($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($collections, "collection", $max-depth)), 265 $dummy := 269 266 if (cmd-model:is-doc-available($names[1], $names[2])) then 270 267 ()
Note: See TracChangeset
for help on using the changeset viewer.