Changeset 681 for MDRepository


Ignore:
Timestamp:
09/08/10 21:05:29 (14 years ago)
Author:
ljo
Message:

cmd-model.xqm - committing before continuing with new change batch.

File:
1 edited

Legend:

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

    r670 r681  
    8484          let $child-results :=
    8585            for $child in $children
    86               let $child-doc := if (empty($child/unresolvable-uri)) then doc(concat(util:collection-name($child/root()), "/", $child/ResourceRef)) else (),
    87                 $child-name := ($child-doc//Corpus/Name, $child-doc//Session/Name, "UNKNOWN")[1]
     86              let $child-doc := if (empty($child/unresolvable-uri)) then
     87                cmd-model:get-resource-by-handle-or-collection-path(util:collection-name($child/root()), $child/ResourceRef) else (),
     88                $child-name := ($child-doc//Corpus/Name, $child-doc//Session/Name, $child-doc//Collection/GeneralInfo/Name, "UNKNOWN")[1]
    8889            return
    8990              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> :)
     
    235236  Get the resource by handle or by path.
    236237:)
    237 declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string) as node()* {
    238   (: fixme! - urldecode $id when we decide to pass them encoded from the client.  :)
    239   if (starts-with($id, "test-")) then
    240     collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = xdb:decode($id)]/ancestor::CMD
     238declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string, $doc-name as xs:string?) as node()* {
     239  if (starts-with($id, "test-") or starts-with($id, "clarin.at") or starts-with($doc-name, "clarin.at")) then
     240    collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = xdb:decode(($doc-name, $id)[1])]/ancestor::CMD
     241  else if (empty($doc-name)) then
     242    collection($id)//IsPartOf[. = "root"]/ancestor::CMD
    241243  else
    242     collection($id)//IsPartOf[. = "root"]/ancestor::CMD
     244    doc(concat($id, "/", $doc-name))
    243245};
    244246
     
    275277        for $collection-item in $collections
    276278        return
    277         for $collection-doc in cmd-model:get-resource-by-handle-or-collection-path($collection-item) return
     279        for $collection-doc in cmd-model:get-resource-by-handle-or-collection-path($collection-item, ()) return
    278280          cmd-model:recurse-collections($collection-doc, ($collection-doc//Corpus/Name, $collection-doc//Session/Name, "UNKNOWN")[1], $collection-doc//MdSelfLink, "", $max-depth)
    279281          return
Note: See TracChangeset for help on using the changeset viewer.