Changeset 743 for MDRepository
- Timestamp:
- 10/04/10 09:16:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MDRepository/trunk/xquery/cmd-model.xqm
r732 r743 39 39 40 40 declare function cmd-model:elem($collections as xs:string+, $path as xs:string, $depth as xs:integer) as element() { 41 (: fixme! - handle multiple collections :)42 cmd-model:elem-r($collections, $path, $depth, $depth)43 };44 45 declare function cmd-model:elem-r($collections as xs:string+, $path as xs:string, $max-depth as xs:integer, $depth as xs:integer) as element() {46 41 let $collection := collection($cmd-model:cmdiMirrorPath), 47 42 $path-nodes := 48 43 if ($collections[1] eq $cmd-model:collectionRoot) then 49 util:eval(fn:concat("$collection/ /", $path))44 util:eval(fn:concat("$collection/descendant-or-self::", $path)) 50 45 else 51 46 for $coll in $collections 52 47 return 53 util:eval(fn:concat("$collection//ft:query(descendant::IsPartOf, <query><term>", xdb:decode($coll), "</term></query>)//", $path, "/ancestor::CMD")) 54 48 util:eval(fn:concat("$collection/ft:query(descendant::IsPartOf, <query><term>", xdb:decode($coll), "</term></query>)/ancestor-or-self::CMD/descendant-or-self::", $path)) 49 return 50 cmd-model:elem-r($path-nodes, $path, $depth, $depth) 51 }; 52 53 declare function cmd-model:elem-r($path-nodes as node()+, $path as xs:string, $max-depth as xs:integer, $depth as xs:integer) as element() { 55 54 let $path-count := count($path-nodes) 56 57 55 let $subs := distinct-values($path-nodes/child::element()/name()) 58 let $text-nodes := $path-nodes//text()56 let $text-nodes := for $node in $path-nodes[child::element()[not(child::element())]] return $node//text() 59 57 let $text-count := count($text-nodes) 60 58 let $text-count-distinct := count(distinct-values($text-nodes)) … … 64 62 (for $elname in $subs[. != ''] 65 63 return 66 cmd-model:elem-r($ collections, concat($path, '/', $elname), $max-depth, $depth - 1),64 cmd-model:elem-r($path-nodes, concat($path, '/', $elname), $max-depth, $depth - 1), 67 65 if ($max-depth eq 1) then cmd-model:values($path-nodes) else ()) 68 66 else 'maxdepth'
Note: See TracChangeset
for help on using the changeset viewer.