Commit 226a8d8d authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

get index list name in transformation

parent b7841ada
......@@ -99,7 +99,7 @@ return
let $ref := substring-after($entity, ":")
let $index := (collection($index:dataPath)/id($ref))[1]
let $name := string($index/*[1])
let $list := local:get-list-by-id($ref)
let $list := index:get-list-by-id($ref)
let $href := "register-" || $list || ".html?e=" || $ref
order by $name
return
......@@ -153,7 +153,7 @@ declare
%test:args("Purschian") (: person :)
%test:assertEquals("listPerson")
function local:get-list-by-id($id as xs:string)
function index:get-list-by-id($id as xs:string)
as xs:string {
let $entity := collection($index:dataPath)/id($id)
let $test := if($entity[2]) then error(QName("FONTANE", "INDEX-API3"), "Entity »" || $id || "« has more then one occurence." ) else ()
......@@ -164,11 +164,11 @@ return
case "place" return "listPlace"
case "person" return
if($entity/ancestor::tei:item)
then local:get-list-by-id( ($entity/ancestor::tei:item)[last()]/string(@xml:id) )
then index:get-list-by-id( ($entity/ancestor::tei:item)[last()]/string(@xml:id) )
else "listPerson"
case "personGrp" return
if($entity/ancestor::tei:item)
then local:get-list-by-id( ($entity/ancestor::tei:item)[last()]/string(@xml:id) )
then index:get-list-by-id( ($entity/ancestor::tei:item)[last()]/string(@xml:id) )
else "listPerson"
default return
let $list := ($entity/ancestor::tei:list[@type])[last()]
......
......@@ -13,6 +13,7 @@ declare namespace tgmd="http://textgrid.info/namespaces/metadata/core/2010";
import module namespace code="http://bdn-edition.de/ns/code-view";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm";
import module namespace index="https://fontane-nb.dariah.eu/indexapi" at "index-api.xqm";
declare variable $fontaneTransfo:tooltipReplacementPattern := '\s$|,$|\.|\($|\)$|;| ';
declare variable $fontaneTransfo:bracket_left.svg := <svg
......@@ -49,6 +50,11 @@ declare variable $fontaneTransfo:bracket_left.svg := <svg
declare variable $fontaneTransfo:dataCollection := collection("/db/sade-projects/textgrid/data/xml/data");
declare variable $fontaneTransfo:base-url :=
if (config:get("sade.develop") = "true")
then "https://fontane-nb.dariah.eu/test/"
else "https://fontane-nb.dariah.eu/";
declare function fontaneTransfo:magic($nodes as node()*) {
fontaneTransfo:magic(($nodes), "undefined")
};
......@@ -1952,11 +1958,7 @@ declare function fontaneTransfo:noteParser($note as node()*) {
element xhtml:span {
attribute class {"target"},
string-join(
(for $xmlid in $xmlids
return
fontaneTransfo:magic($node/root()//*[@xml:id=$xmlid]))
//text()
[not(parent::*[contains(@class, "expan")])]
"blablubb"
, " ") || "]"
},
element xhtml:ul {
......@@ -1994,8 +1996,10 @@ declare function fontaneTransfo:noteParser($note as node()*) {
if( matches($node/@target, $pattern))
then
element xhtml:a {
attribute href {"https://fontane-nb.dariah.eu/" || (if(config:get("sade.develop") = "true") then "test/" else "") || "edition.html?id=%2Fxml%2Fdata%2F"|| $uri ||".xml&amp;page="||$targetParts[2]||"&amp;target="||substring-after($node/@target, "#")},
fontaneTransfo:noteParser($node/node())
attribute href {$fontaneTransfo:base-url || "edition.html?id=%2Fxml%2Fdata%2F"|| $uri ||".xml&amp;page="||$targetParts[2]||"&amp;target="||substring-after($node/@target, "#"),
fontaneTransfo:noteParser($node/node()),
$node/node()
}
}
else <xhtml:span style="color:red; font-weight:bold"> tei:ref/@target does not macht »{$pattern}« </xhtml:span>
case element( tei:seg ) return
......@@ -2024,9 +2028,10 @@ declare function local:teiref2href($ref as xs:string) as xs:string {
let $id := substring-after($ref, ":")
return
switch ($prefix)
case "lit" return "https://fontane-nb.dariah.eu/literaturvz.html?id="||$id
case "wrk" return "https://fontane-nb.dariah.eu/test/register.html?e=" || $id
default return error(QName("https://fontane-nb.dariah.eu/error", "REF01"), "Unsupported type for @tei:ref. Must start with »lit:« or »wrk:«")
case "lit" return $fontaneTransfo:base-url || "literaturvz.html?id=" || $id
default return
let $listName := index:get-list-by-id($id)
return $fontaneTransfo:base-url || $listName || ".html?e=" || $id
};
declare function fontaneTransfo:figure($node as node()*) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment