Commit bcf7c7e8 authored by dje's avatar dje
Browse files

ajustements compatibilité basex867

parent 31b3d815
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -60,9 +60,14 @@ declare function max.util:buildXSLTDoc($xsltMain as xs:string, $xsltAddons as xs
lists collection' sub collections 
:)
declare function max.util:children-collection($dbName, $collection){
  let $path := if($collection = '') then '' else $collection || "/"
  let $dbAndColl:= if(contains($dbName,'/'))
    then (substring-before($dbName,'/')[1],substring-after($dbName,'/'))
    else ($dbName,$collection)
  
  
  let $path := if($collection = '') then '' else $dbAndColl[2] || "/"
  return distinct-values(
    for $doc in db:list($dbName) where starts-with($doc, $path)
    for $doc in db:list($dbAndColl[1]) where starts-with($doc, $path)
    let $subCollection := substring-before(substring-after($doc, $path), "/")
    return  
     if(normalize-space($subCollection) = '')
@@ -98,8 +103,12 @@ declare function max.util:recursive-children-collection($dbName, $collection, $h
Lists collection 's document (not recursive)
:)
declare function max.util:doc-in-collection($dbName, $collection){
  for $doc in db:list($dbName, $collection)
  let $path := if($collection='') then '' else $collection || '/'
   let $dbAndColl:= if(contains($dbName,'/'))
    then (substring-before($dbName,'/')[1],substring-after($dbName,'/'))
    else ($dbName,$collection)
    
  for $doc in db:list($dbAndColl[1], $dbAndColl[2])
  let $path := if($dbAndColl[2]='') then '' else $dbAndColl[2] || '/'
  return if(($path || file:name($doc)) = $doc)
  then $doc
  else ()