Commit 7efffcb9 authored by chauveau's avatar chauveau
Browse files

parse HTML custom (fetch XML) pour éviter les bugs d(HTML entities non reconnues sur les fragments

parent 4ef4fa03
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -396,4 +396,3 @@ declare


+2 −1
Original line number Diff line number Diff line
@@ -382,7 +382,8 @@ declare %private function max.html:buildSubMenu($projectId, $pageId){
declare function max.html:getHTMLFragment($project, $fragmentName as xs:string)
as element(div){
    let $fragmentPath := max.util:maxHome() ||"/editions/"||$project|| "/fragments/"||$fragmentName|| ".frag.html"
    return  <div id='content'>{doc($fragmentPath)}</div> 
    let $content :=   fetch:xml($fragmentPath, map { 'parser': 'html','htmlparser': map { 'html': false(), 'nodefaults': true() }})
    return  <div id='content'>{$content}</div> 
};

(:gets a project static HTML fragment (wrapped in an html div):)
+16 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ knowledge of the CeCILL-B license and that you accept its terms.
:)
module namespace max.api = 'pddn/max/max_api';


import module namespace max.util = 'pddn/max/util' at 'util.xqm';

(:Returns XML fragment identified by $id:)
declare
@@ -99,6 +99,20 @@ function max.api:getXMLByID($db, $id, $q){
    }
};

(:Returns XML fragment in a specified document :)
declare
%rest:GET
%output:method("html")
%rest:path("/sf/{$routeDoc=.*\.xml|.*\.svg}/{$id}")
function max.api:getXMLByIDinDOC($routeDoc, $id){
  try{
        doc($routeDoc)//*[@xml:id=$id or @id=$id][1]  
    }
    catch *{
      <div class='error'>{'Error [' || $err:code || '/' || $err:module || '/' || $err:line-number ||']: ' || $err:description}</div>
    }
};

declare function max.api:getXMLByID($db, $id){
   max.api:getXMLByID($db, $id, ())
};
@@ -133,3 +147,4 @@ function max.api:getXMLByIDInDoc($doc, $id){



+2 −2
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ knowledge of the CeCILL-B license and that you accept its terms.
module namespace max.util = 'pddn/max/util';
declare namespace xsl = "http://www.w3.org/1999/XSL/Transform";


(:
: Returns binary-file
:)
@@ -259,3 +258,4 @@ declare function max.util:listContextFunction(){
  </ul>
  
};