Commit 74999f31 authored by mrodzis's avatar mrodzis 🌎
Browse files

Ignore surplus tei:rs

parent e9d6c600
......@@ -20,6 +20,7 @@ declare namespace xlink="http://www.w3.org/1999/xlink";
import module namespace console="http://exist-db.org/xquery/console";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
import module namespace tbleapi="https://fontane-nb.dariah.eu/tble" at "../tble-api.xqm";
import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at "index-info.xqm";
(:~
......@@ -157,8 +158,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node()))
else
fontaneSimple:transform($node/node()),
text{" "})
fontaneSimple:transform($node/node()))
case element(tei:addSpan) return
if($node/@type = "edited_text") then
......@@ -599,7 +599,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
$node/@*,
(: TODO: generalize :)
attribute href {fontaneSimple:make-link-to-sketch("16b00", $node/@xml:id)},
attribute href {tbleapi:get-url("16b00", $node/@xml:id, "png")},
attribute height-in-mm {fontaneSimple:get-height-in-mm("16b00", $node/@xml:id)},
fontaneSimple:transform($nodes/node())
}
......@@ -651,12 +651,18 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:rs) return
let $index-type := substring-before($node/@ref, ":")
return
(element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
fontaneSimple:make-index-infos($node, $index-type),
fontaneSimple:transform($node/node())
},
text{" "})
(: ignore tei:rs elements that are empty after presorting. this
is important because they would cause a lot of whitespace trouble
otherwise :)
if($node//text()[matches(., "[\w]")]) then
(element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
fontaneSimple:make-index-infos($node, $index-type),
fontaneSimple:transform($node/node())
},
text{" "})
else
()
case element(tei:date) return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
......@@ -935,33 +941,6 @@ as element(tei:term)* {
()
};
(:~
: @param $current-uri The URI of the current notebook, e.g. '16b00' :)
declare function fontaneSimple:make-link-to-sketch($current-uri as xs:string,
$xml-id as xs:string) as xs:string {
let $tble-coll := collection("/db/sade-projects/textgrid/data/xml/tile/")
let $full-uri := "textgrid:" || $current-uri
let $file := for $res in $tble-coll return
(: REGEX is necessary to be independent from revisions :)
if($res//tei:link[matches(@targets, $full-uri || "\.[0-9]+#" || $xml-id)
and matches(@targets, "shape")]) then
$res
else
()
let $shape := $file//tei:link[matches(@targets, $full-uri || "\.[0-9]+#" || $xml-id)
and matches(@targets, "shape")]/@targets
=> substring-before(" ")
=> replace("#", "")
let $shape-info := $file//svg:*[@id = $shape]
let $coordinates := $shape-info/@x || "," || $shape-info/@y || "," ||
$shape-info/@width || "," || $shape-info/@height
let $coordinates := replace($coordinates, "%", "")
let $img-uri := $shape-info/preceding-sibling::svg:image/@xlink:href
let $url := "https://textgridlab.org/1.0/digilib/rest/IIIF/" || $img-uri ||
"/pct:" || $coordinates || "/1000,/0/default.jpg"
return $url
};
(:~
: @param $current-uri The URI of the current notebook, e.g. '16b00' :)
......
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