Loading src/main/bundles/max-dumb-xml/dumb-xml/dumb-xml.xqm +19 −14 Original line number Diff line number Diff line Loading @@ -10,21 +10,26 @@ import module namespace i18n = "https://certic.unicaen.fr/max/i18n" at '../../.. import module namespace database = "https://certic.unicaen.fr/max/database" at '../../../core/database.xqm'; import module namespace errors = "https://certic.unicaen.fr/max/errors" at '../../../core/errors.xqm'; declare function dumb-xml:doc-to-html($document as document-node(), $lang as xs:string){ declare function dumb-xml:doc-to-html($document as document-node(), $lang as xs:string) as element(html){ let $customXQ := file:current-dir()|| '/xq/document.xq' let $content := if(file:exists($customXQ)) then xquery:eval(xs:anyURI($customXQ), map {'doc': $document, 'lang': $lang}) else (:generate random http link to an identified node in $document:) let $identifiers:= $document//*/@xml:id/string() let $n := count($identifiers) let $r := random:integer($n) + 1 let $target := $identifiers[$r] let $href := fn:replace(request:path(),'.html', '') || '/id/' || $target || '.html' let $content := <div> return <div> <h2>{i18n:translate('raw', $lang)} | {fn:replace(fn:base-uri($document), '/' || $database:max-db || '/', '')}</h2> {$document} <nav> <h3><a href="{$href}">{i18n:translate('random-link', $lang)} ({$target})</a></h3> </nav> </div> return templating:render('page.html', map {'content': $content, 'lang': $lang}) }; Loading Loading
src/main/bundles/max-dumb-xml/dumb-xml/dumb-xml.xqm +19 −14 Original line number Diff line number Diff line Loading @@ -10,21 +10,26 @@ import module namespace i18n = "https://certic.unicaen.fr/max/i18n" at '../../.. import module namespace database = "https://certic.unicaen.fr/max/database" at '../../../core/database.xqm'; import module namespace errors = "https://certic.unicaen.fr/max/errors" at '../../../core/errors.xqm'; declare function dumb-xml:doc-to-html($document as document-node(), $lang as xs:string){ declare function dumb-xml:doc-to-html($document as document-node(), $lang as xs:string) as element(html){ let $customXQ := file:current-dir()|| '/xq/document.xq' let $content := if(file:exists($customXQ)) then xquery:eval(xs:anyURI($customXQ), map {'doc': $document, 'lang': $lang}) else (:generate random http link to an identified node in $document:) let $identifiers:= $document//*/@xml:id/string() let $n := count($identifiers) let $r := random:integer($n) + 1 let $target := $identifiers[$r] let $href := fn:replace(request:path(),'.html', '') || '/id/' || $target || '.html' let $content := <div> return <div> <h2>{i18n:translate('raw', $lang)} | {fn:replace(fn:base-uri($document), '/' || $database:max-db || '/', '')}</h2> {$document} <nav> <h3><a href="{$href}">{i18n:translate('random-link', $lang)} ({$target})</a></h3> </nav> </div> return templating:render('page.html', map {'content': $content, 'lang': $lang}) }; Loading