Commit 4065cbbe authored by Pierre-Yves Buard's avatar Pierre-Yves Buard
Browse files

Gestion des ressouces manquantes

parent e49e4e61
Loading
Loading
Loading
Loading
+19 −7
Changes for plugins/index/index.xqm: 19 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
module namespace max.plugin.index = 'pddn/max/plugin/index';
import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm';
import module namespace max.html = 'pddn/max/html' at '../../rxq/html.xqm';
import module namespace max.util = 'pddn/max/util' at '../../rxq/util.xqm';

declare variable $max.plugin.index:PLUGIN_ID := "index";

@@ -27,11 +28,24 @@ function max.plugin.index:index($project,$type){
declare function max.plugin.index:generateIndex($project,$type){  
let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index_'||$type||'.frag.html'

let $HTMLIndex := max.plugin.index:loadIndex($project,$type)
return file:write($indexFilePath, <div class='index'>{$HTMLIndex}</div>), max.plugin.index:index($project,$type)
let $custXQ := file:parent(file:parent(file:parent(static-base-uri())))||"editions/"||$project||"/xq/index_"||$type||".xq"
let $custXSL := file:parent(file:parent(file:parent(static-base-uri())))||"editions/"||$project||"/ui/xsl/index_"||$type||".xsl"

let $HTMLIndex := if (file:exists($custXQ) and file:exists($custXSL))
                  then max.plugin.index:loadIndex($project,$type,$custXQ,$custXSL)
                  else "error"

let $res := switch ($HTMLIndex)
        case "error"
           return "XQ and/or XSL file not found"
        default
           return file:write($indexFilePath, <div class='index'>{$HTMLIndex}</div>)(: , max.plugin.index:index($project,$type) :)
           
return if (file:exists($indexFilePath)) then max.plugin.index:index($project,$type)
       else $res
};

declare function max.plugin.index:loadIndex($edition,$type) {
declare function max.plugin.index:loadIndex($edition,$type,$xq,$xsl) {
  let $dbPath := max.config:getProjectDBPath($edition)
  let $projectIndex := if($type='typesdocs')
                       then <index type="typesdocs">{
@@ -42,13 +56,11 @@ declare function max.plugin.index:loadIndex($edition,$type) {
                         let $cUnitid := $idx/ancestor::*:c[1]/descendant::*:unitid[1]/text()
                         let $result := <marker id="{$cId}" otherlevel="{$cOtherlevel}"><entry>{$cUnitid}</entry><value>{$idx/text()}</value></marker>
                         return $result}</index>
                       else let $custIndex := file:parent(file:parent(file:parent(static-base-uri())))||"editions/"||$edition||"/xq/index_"||$type||".xq"
                         return if (file:exists($custIndex)) then xquery:eval(xs:anyURI($custIndex))
                       else xquery:eval(xs:anyURI($xq)) 

  let $HTMLProjectIndex := if($type='typesdocs')
                             then xslt:transform($projectIndex, 'indexing.xsl', ())
                           else let $custXSL := file:parent(file:parent(file:parent(static-base-uri())))||"editions/"||$edition||"/ui/xsl/index_"||$type||".xsl"
                             return if (file:exists($custXSL)) then xslt:transform($projectIndex, $custXSL, ())
                           else xslt:transform($projectIndex, $xsl, ()) 

  return $HTMLProjectIndex
};
 No newline at end of file