: prepares URLs to textgrid digilib for given tei:surface
: TODO: should work with tei:graphic
:
: :)
declare function transfo:digilib($node){
(: TILE object available :)
if($node/tei:graphic/@xml:id)
if($node/tei:graphic[1]/@xml:id)
then
transfo:image-tile($node/tei:graphic[1])
else
(: typical cover :)
transfo:image($node/tei:graphic[1])
};
let $id := ($node/tei:graphic/string(@xml:id))[1]
let $uri := $node/ancestor::tei:TEI//tei:publicationStmt//tei:idno[@type="TextGrid"]/string(.)
(:~
:
: prepares a URL to digilib (IIIF) for a given tei element
:
: @param $graphic a tei element like graphic or figure with a xml:id
: @return a URL to digilib
: :)
declare function transfo:image-tile($graphic as element(*))
as xs:string {
let $id := $graphic/string(@xml:id)
let $uri := $graphic/root()//tei:publicationStmt//tei:idno[@type="TextGrid"]/string(.)
let $link := transfo:newestTBLELink($uri, $id)
let $facs := $link/parent::tei:linkGrp/substring-after(@facs, '#')
let $tei := $link/ancestor::tei:TEI
let $shape := $link/parent::tei:linkGrp/tei:link[contains(@targets, 'shape')][ends-with(@targets, $id)]/substring-before(substring-after(@targets, '#'), ' ')
let $link := transfo:newestTBLELink($uri, $id)
let $facs := $link/parent::tei:linkGrp/substring-after(@facs, '#')
let $tei := $link/ancestor::tei:TEI
let $shape := $link/parent::tei:linkGrp/tei:link[contains(@targets, 'shape')][ends-with(@targets, $id)]/substring-before(substring-after(@targets, '#'), ' ')
let $svgg := $tei//svg:g[@id = $facs]
let $image := string($svgg/svg:image/@xlink:href)
let $image := if ($image = "") then $node/tei:graphic/substring-after(@url, "http://textgridrep.org/") else $image
let $svgg := $tei//svg:g[@id = $facs]
let $image := string($svgg/svg:image/@xlink:href)
let $image := if ($image = "") then $graphic/substring-after(@url, "http://textgridrep.org/") else $image
let $x := number($svgg//svg:rect[@id = $shape]/substring-before(@x, '%')) (: div 100 :)
let $y := number($svgg//svg:rect[@id = $shape]/substring-before(@y, '%')) (: div 100 :)
let $w := number($svgg//svg:rect[@id = $shape]/substring-before(@width, '%')) (: div 100 :)
let $h := number($svgg//svg:rect[@id = $shape]/substring-before(@height, '%')) (: div 100 :)
let $x := xs:decimal($svgg//svg:rect[@id = $shape]/substring-before(@x, '%')) (: div 100 :)
let $y := xs:decimal($svgg//svg:rect[@id = $shape]/substring-before(@y, '%')) (: div 100 :)
let $w := xs:decimal($svgg//svg:rect[@id = $shape]/substring-before(@width, '%')) (: div 100 :)
let $h := xs:decimal($svgg//svg:rect[@id = $shape]/substring-before(@height, '%')) (: div 100 :)
return
'https://textgridlab.org/1.0/digilib/rest/IIIF/'
|| $image
|| '/pct:'
|| string-join(($x, $y, $w, $h), ",")
|| '/,500/0/default.jpg'
return
'https://textgridlab.org/1.0/digilib/rest/IIIF/'
|| $image
|| '/pct:'
|| string-join(($x, $y, $w, $h), ",")
|| '/,500/0/default.jpg'
};
else
(: typical cover :)
(:~
: prepares a URL to digilib
:
: @param $graphic A tei element like graphic and figure
: @return a URL like https://textgridlab.org/1.0/digilib/rest/IIIF/textgrid:164g9.1/pct:7.747474581830108,5.289308105687416,84.44747294194818,89.91823779668606/,1000/0/default.jpg
: :)
declare function transfo:image($graphic as element(*))