Commit bc6eef84 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Closes #46

parent 4ca44fb7
......@@ -13,8 +13,10 @@ xquery version "3.1";
module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple";
declare namespace svg="http://www.w3.org/2000/svg";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
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";
......@@ -590,6 +592,8 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else if($node/ancestor::tei:zone[@type = "illustration"]) then
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)},
fontaneSimple:transform($nodes/node())
}
else
......@@ -921,4 +925,31 @@ as element(tei:term)* {
}
else
()
};
(:~
: @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
};
\ No newline at end of file
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