Loading plugins/index/index.xqm +20 −58 Changes for plugins/index/index.xqm: 20 added lines, 58 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ 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'; declare variable $max.plugin.index:PLUGIN_ID := "index"; (: returns index fragment if exists (already generated) returns a news generated one if not Loading @@ -11,68 +13,28 @@ returns a news generated one if not declare %rest:GET %output:method("html") %rest:path("/editions/{$project}/index") %rest:path("/{$project}/index") function max.plugin.index:index($project){ let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index.frag.html' return if(file:exists($indexFilePath)) then let $content := <div id='content'>{doc($indexFilePath)}</div> return max.html:render($project, 'index', $content) else max.plugin.index:generateIndex($project) }; declare function max.plugin.index:generateIndex($project){ try{ let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index.frag.html' let $dbPath := max.config:getProjectDBPath($project) let $backToTextPath := max.config:getPluginParameterValue($project, 'index', 'backToText') let $persons := <listPerson> { for $i at $p in collection($dbPath)//*:name[@*:type='personne' and @*:ref] group by $ref:=$i/@*:ref return if(starts-with($ref,'http')) then () else let $id := substring-after($ref,'#') return if(not($id)) then error(xs:QName('max.error'),'ID IS -' || $ref) else let $url := max.config:getPluginParameterValue($project, 'index', 'url') || $id ||'.xml' let $request := <http:request href='{$url}' method='post' username="{max.config:getPluginParameterValue($project, 'index', 'login')}" password="{max.config:getPluginParameterValue($project, 'index', 'password')}" send-authorization='true'> <http:body media-type='application/xml'> <query xmlns="http://basex.org/rest"> <text><![CDATA[ <person xml:id='{//*:TEI/@xml:id/string()}'>{//*:TEI//*:person} </person> ]]></text> </query> </http:body> </http:request> let $person := http:send-request($request) let $occurs:= <div type='occurs'>{ for $n at $j in collection($dbPath)//*:name[@*:type='personne' and @*:ref=$ref] let $target:=substring-after(base-uri($n),$dbPath)||'/'||xquery:eval($backToTextPath, map { '': $n}) return <a target="./{$target}">{$j}</a> } </div> return <item>{$person}{$occurs}</item> }</listPerson> let $HTMLIndex := xslt:transform($persons, 'indexing.xsl', ()) (:return file:write($indexFilePath, <div class='index'>{$HTMLIndex}</div>), max.plugin.index:index($project):) return max.html:render($project, 'index', <div class='index'>{$HTMLIndex}</div>) } catch experr:HC0001{<div>Check your Index Plugin Config- TRACE: {$err:description} - {$err:module} - {$err:line-number}</div>} }; let $idxGenreform := <index type="Type de documents">{for $idx in collection($dbPath)//*:controlaccess/*:genreform let $cId := $idx/ancestor::*:c[1]/@id let $cOtherlevel := $idx/ancestor::*:c[1]/@otherlevel 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> let $idxPerson := <index type="Personnes">{for $idx in collection($dbPath)//*:persname let $cId := $idx/ancestor::*:c[1]/@id let $cOtherlevel := $idx/ancestor::*:c[1]/@otherlevel let $role := $idx/@role let $cUnitid := $idx/ancestor::*:c[1]/descendant::*:unitid[1]/text() let $result := <marker id="{$cId}" otherlevel="{$cOtherlevel}" role="{$role}"><entry>{$cUnitid}</entry><value>{data($idx/@normal)}</value></marker> return $result}</index> let $idx := <idx>{$idxGenreform}{$idxPerson}</idx> declare %private function max.plugin.index:generateIndexToDonwload($project){ let $HTMLIndex := xslt:transform($idx, 'indexing.xsl', ()) return max.html:render($project, 'index', <div class='index'>{$HTMLIndex}</div>) () }; No newline at end of file plugins/index/indexing.xsl +47 −49 Changes for plugins/index/indexing.xsl: 47 added lines, 49 removed lines. Original line number Diff line number Diff line Loading @@ -4,63 +4,61 @@ --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:isbn:1-931666-22-9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xinclude="http://www.w3.org/2001/XInclude" xmlns:xhtml="http://www.w3.org/TR/xhtml/strict" xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="tei xsl"> xmlns:ns="urn:isbn:1-931666-22-9" xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="tei xsl xsi xs xlink xinclude xhtml tei ns hfp"> <xsl:output method="xml" encoding="utf-8"/> <xsl:template match='/'> <ul> <xsl:for-each-group select="//tei:person" group-by="substring(normalize-space(string-join(.//tei:persName//text(),'')),1,1)"> <xsl:sort select="current-grouping-key()" /> <li class="index-letter-block"> <h2><xsl:value-of select="current-grouping-key()"/></h2> <ul> <xsl:for-each select="current-group()"> <xsl:sort select="." /> <li class='index-block'><h3><xsl:value-of select="./ancestor::*:person[last()]/@xml:id"/></h3> <ul> <xsl:apply-templates /> </ul> <xsl:apply-templates select="./ancestor::*:item[last()]/*:div[@*:type='occurs']"/> </li> </xsl:for-each> </ul> </li> </xsl:for-each-group> </ul> </xsl:template> <xsl:template match='tei:persName'> <xsl:variable name='class'><xsl:value-of select="@xml:lang"/></xsl:variable> <!--<xsl:if test="$class='fr'"> <li>ID = <xsl:value-of select="./ancestor::*:person[last()]/@xml:id"/></li> </xsl:if>--> <li class='{$class}'><xsl:value-of select="."/><span class='lang'> [<xsl:value-of select="$class"/>]</span></li> </xsl:template> <xsl:template match='tei:birth'> <li class='birth'>Né(e) le <xsl:value-of select="."/></li> </xsl:template> <xsl:template match='tei:death'> <li class='death'>Décédé(e) le <xsl:value-of select="."/></li> <xsl:template match="/idx"> <div class="idx"> <xsl:apply-templates/> </div> </xsl:template> <xsl:template match='div'> <div class='occurs'><xsl:apply-templates /></div> </xsl:template> <xsl:template match='a'> <a class='index-link' href='{./@target}'><xsl:value-of select="."/></a> <xsl:template match="index[@type='Type de documents']"> <div class="{./@type}"> <h1> <xsl:value-of select="@type"/> </h1> <xsl:for-each-group select="./descendant::marker" group-by="./value"> <h2> <xsl:value-of select="current-grouping-key()"/> </h2> <div class="entries"> <xsl:value-of select="current-group()/entry" separator=" ; "/> </div> </xsl:for-each-group> </div> </xsl:template> <xsl:template match='tei:occupation | tei:note'> <!-- TODO --> <xsl:template match="index[@type='Personnes']"> <div class="{./@type}"> <h1> <xsl:value-of select="@type"/> </h1> <xsl:for-each-group select="./descendant::marker" group-by="./@role"> <h2> <xsl:value-of select="current-grouping-key()"/> </h2> <xsl:for-each-group select="current-group()" group-by="./value"> <h3> <xsl:value-of select="current-grouping-key()"/> </h3> <div class="entries"> <xsl:value-of select="current-group()/entry" separator=" ; "/> </div> </xsl:for-each-group> </xsl:for-each-group> </div> </xsl:template> <!-- <xsl:for-each-group select="record" group-by="info/date"> </xsl:for-each-group> --> </xsl:stylesheet> No newline at end of file Loading
plugins/index/index.xqm +20 −58 Changes for plugins/index/index.xqm: 20 added lines, 58 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ 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'; declare variable $max.plugin.index:PLUGIN_ID := "index"; (: returns index fragment if exists (already generated) returns a news generated one if not Loading @@ -11,68 +13,28 @@ returns a news generated one if not declare %rest:GET %output:method("html") %rest:path("/editions/{$project}/index") %rest:path("/{$project}/index") function max.plugin.index:index($project){ let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index.frag.html' return if(file:exists($indexFilePath)) then let $content := <div id='content'>{doc($indexFilePath)}</div> return max.html:render($project, 'index', $content) else max.plugin.index:generateIndex($project) }; declare function max.plugin.index:generateIndex($project){ try{ let $indexFilePath :=file:parent(file:parent(file:parent(static-base-uri()))) || '/editions/'||$project||'/fragments/index.frag.html' let $dbPath := max.config:getProjectDBPath($project) let $backToTextPath := max.config:getPluginParameterValue($project, 'index', 'backToText') let $persons := <listPerson> { for $i at $p in collection($dbPath)//*:name[@*:type='personne' and @*:ref] group by $ref:=$i/@*:ref return if(starts-with($ref,'http')) then () else let $id := substring-after($ref,'#') return if(not($id)) then error(xs:QName('max.error'),'ID IS -' || $ref) else let $url := max.config:getPluginParameterValue($project, 'index', 'url') || $id ||'.xml' let $request := <http:request href='{$url}' method='post' username="{max.config:getPluginParameterValue($project, 'index', 'login')}" password="{max.config:getPluginParameterValue($project, 'index', 'password')}" send-authorization='true'> <http:body media-type='application/xml'> <query xmlns="http://basex.org/rest"> <text><![CDATA[ <person xml:id='{//*:TEI/@xml:id/string()}'>{//*:TEI//*:person} </person> ]]></text> </query> </http:body> </http:request> let $person := http:send-request($request) let $occurs:= <div type='occurs'>{ for $n at $j in collection($dbPath)//*:name[@*:type='personne' and @*:ref=$ref] let $target:=substring-after(base-uri($n),$dbPath)||'/'||xquery:eval($backToTextPath, map { '': $n}) return <a target="./{$target}">{$j}</a> } </div> return <item>{$person}{$occurs}</item> }</listPerson> let $HTMLIndex := xslt:transform($persons, 'indexing.xsl', ()) (:return file:write($indexFilePath, <div class='index'>{$HTMLIndex}</div>), max.plugin.index:index($project):) return max.html:render($project, 'index', <div class='index'>{$HTMLIndex}</div>) } catch experr:HC0001{<div>Check your Index Plugin Config- TRACE: {$err:description} - {$err:module} - {$err:line-number}</div>} }; let $idxGenreform := <index type="Type de documents">{for $idx in collection($dbPath)//*:controlaccess/*:genreform let $cId := $idx/ancestor::*:c[1]/@id let $cOtherlevel := $idx/ancestor::*:c[1]/@otherlevel 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> let $idxPerson := <index type="Personnes">{for $idx in collection($dbPath)//*:persname let $cId := $idx/ancestor::*:c[1]/@id let $cOtherlevel := $idx/ancestor::*:c[1]/@otherlevel let $role := $idx/@role let $cUnitid := $idx/ancestor::*:c[1]/descendant::*:unitid[1]/text() let $result := <marker id="{$cId}" otherlevel="{$cOtherlevel}" role="{$role}"><entry>{$cUnitid}</entry><value>{data($idx/@normal)}</value></marker> return $result}</index> let $idx := <idx>{$idxGenreform}{$idxPerson}</idx> declare %private function max.plugin.index:generateIndexToDonwload($project){ let $HTMLIndex := xslt:transform($idx, 'indexing.xsl', ()) return max.html:render($project, 'index', <div class='index'>{$HTMLIndex}</div>) () }; No newline at end of file
plugins/index/indexing.xsl +47 −49 Changes for plugins/index/indexing.xsl: 47 added lines, 49 removed lines. Original line number Diff line number Diff line Loading @@ -4,63 +4,61 @@ --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:isbn:1-931666-22-9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xinclude="http://www.w3.org/2001/XInclude" xmlns:xhtml="http://www.w3.org/TR/xhtml/strict" xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="tei xsl"> xmlns:ns="urn:isbn:1-931666-22-9" xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="tei xsl xsi xs xlink xinclude xhtml tei ns hfp"> <xsl:output method="xml" encoding="utf-8"/> <xsl:template match='/'> <ul> <xsl:for-each-group select="//tei:person" group-by="substring(normalize-space(string-join(.//tei:persName//text(),'')),1,1)"> <xsl:sort select="current-grouping-key()" /> <li class="index-letter-block"> <h2><xsl:value-of select="current-grouping-key()"/></h2> <ul> <xsl:for-each select="current-group()"> <xsl:sort select="." /> <li class='index-block'><h3><xsl:value-of select="./ancestor::*:person[last()]/@xml:id"/></h3> <ul> <xsl:apply-templates /> </ul> <xsl:apply-templates select="./ancestor::*:item[last()]/*:div[@*:type='occurs']"/> </li> </xsl:for-each> </ul> </li> </xsl:for-each-group> </ul> </xsl:template> <xsl:template match='tei:persName'> <xsl:variable name='class'><xsl:value-of select="@xml:lang"/></xsl:variable> <!--<xsl:if test="$class='fr'"> <li>ID = <xsl:value-of select="./ancestor::*:person[last()]/@xml:id"/></li> </xsl:if>--> <li class='{$class}'><xsl:value-of select="."/><span class='lang'> [<xsl:value-of select="$class"/>]</span></li> </xsl:template> <xsl:template match='tei:birth'> <li class='birth'>Né(e) le <xsl:value-of select="."/></li> </xsl:template> <xsl:template match='tei:death'> <li class='death'>Décédé(e) le <xsl:value-of select="."/></li> <xsl:template match="/idx"> <div class="idx"> <xsl:apply-templates/> </div> </xsl:template> <xsl:template match='div'> <div class='occurs'><xsl:apply-templates /></div> </xsl:template> <xsl:template match='a'> <a class='index-link' href='{./@target}'><xsl:value-of select="."/></a> <xsl:template match="index[@type='Type de documents']"> <div class="{./@type}"> <h1> <xsl:value-of select="@type"/> </h1> <xsl:for-each-group select="./descendant::marker" group-by="./value"> <h2> <xsl:value-of select="current-grouping-key()"/> </h2> <div class="entries"> <xsl:value-of select="current-group()/entry" separator=" ; "/> </div> </xsl:for-each-group> </div> </xsl:template> <xsl:template match='tei:occupation | tei:note'> <!-- TODO --> <xsl:template match="index[@type='Personnes']"> <div class="{./@type}"> <h1> <xsl:value-of select="@type"/> </h1> <xsl:for-each-group select="./descendant::marker" group-by="./@role"> <h2> <xsl:value-of select="current-grouping-key()"/> </h2> <xsl:for-each-group select="current-group()" group-by="./value"> <h3> <xsl:value-of select="current-grouping-key()"/> </h3> <div class="entries"> <xsl:value-of select="current-group()/entry" separator=" ; "/> </div> </xsl:for-each-group> </xsl:for-each-group> </div> </xsl:template> <!-- <xsl:for-each-group select="record" group-by="info/date"> </xsl:for-each-group> --> </xsl:stylesheet> No newline at end of file