Commit 039b6640 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

fast fertig

parent 34a26cd6
......@@ -16,7 +16,6 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare variable $fontaneregister:metaCollection := '/db/sade-projects/textgrid/data/xml/meta/';
declare variable $fontaneregister:get-entity := request:get-parameter('e', '');
declare variable $fontaneregister:get-register := request:get-parameter('r', '');
declare variable $fontaneregister:get-notebook := request:get-parameter('nb', 'all');
(:~
......@@ -69,6 +68,64 @@ element {"xhtml:li"} {
}
};
(:~
: Main function to create a complete index, contains some template specific
: code.
:
: :)
declare function fontaneregister:register() as element(xhtml:div){
let $agg := '253st.xml' (: TextGrid Aggregation containing all index files :)
let $uris := doc('/db/sade-projects/textgrid/data/xml/agg/'||$agg)//ore:aggregates/substring-after(@rdf:resource, 'textgrid:')
let $meta := for $uri in $uris
where doc-available( '/db/sade-projects/textgrid/data/xml/data/' || $uri ||'.xml')
return
doc('/db/sade-projects/textgrid/data/xml/meta/'||$uri||'.xml')
let $docs := $meta//tgmd:textgridUri/tokenize(., ':|\.')[2] ! doc('/db/sade-projects/textgrid/data/xml/data/' || . ||'.xml')
let $tabs :=
<ul class="nav nav-tabs" style="font-size: smaller;">
{for $i at $pos in $meta
let $uri := $i//tgmd:textgridUri/tokenize(., ':|\.')[2]
let $doc := doc('/db/sade-projects/textgrid/data/xml/data/' || $uri ||'.xml')
where not(matches($uri,"25547|253t3"))
return
<li>
{ attribute class { local:check-entity($doc/*) } }
<a data-toggle="tab" href="#r{ $uri }">{$i//tgmd:title/text()}</a>
</li>,
(: need to hardcode stuff comming from a singe tei file: :)
<li>
{ attribute class { local:check-entity($docs//tei:body//tei:list[@type="works"]) } }
<a data-toggle="tab" href="#r253t3-works">Werke</a>
</li>,
<li>
{ attribute class { local:check-entity($docs//tei:body//tei:list[@type="periodicals"]) } }
<a data-toggle="tab" href="#r253t3-Fontane">Fontanes Werke</a>
</li>,
<li>
{ attribute class { local:check-entity($docs//tei:body//tei:list[@type="Fontane"]) } }
<a data-toggle="tab" href="#r253t3-periodicals">Periodika</a>
</li>
}
</ul>
return
<div class="container">
{$tabs}
<div class="tab-content">
{ fontaneregister:events( $docs//tei:body/tei:listEvent ),
fontaneregister:orgs( $docs//tei:body/tei:listOrg ),
fontaneregister:persons( $docs//tei:body/tei:listPerson ),
fontaneregister:places( $docs//tei:body/tei:listPlace ),
fontaneregister:works( $docs//tei:body//tei:list[@type="works"] ),
fontaneregister:works( $docs//tei:body//tei:list[@type="periodicals"] ),
fontaneregister:works( $docs//tei:body//tei:list[@type="Fontane"] )
}
</div>
</div>
};
(:~
: parser for listEvents/event entities
: :)
......@@ -87,7 +144,7 @@ return
</div>
<div class="panel-body">
<ul class="listEvent">
{$eventList/tei:event ! local:prepare-event(., $eventDoc-uri)}
{$eventList/tei:event ! local:prepare-event(.)}
</ul>
</div>
</div>
......@@ -96,11 +153,12 @@ return
</div>
};
declare function local:prepare-event($e as element(tei:event), $uri as xs:string) as element(xhtml:li) {
declare function local:prepare-event($e as element(tei:event)) as element(xhtml:li) {
let $id := $e/@xml:id
let $where := substring-after($e/@where, ":")
let $label-main := ($e/tei:label)[1]
let $label-alt := ($e/tei:label)[position() gt 1]
let $label-alt := ($e/tei:label[not(@type="variant")])[position() gt 1]
let $variant := $e/tei:label[@type="variant"]
let $note := $e/tei:note
let $bibl := $e/tei:bibl
let $links := $e/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
......@@ -127,9 +185,7 @@ return
attribute { "class" } {"registerLink"},
element { "xhtml:a" } {
attribute { "href" } {
"register.html?" ||
"r=" || $uri ||
"&amp;e=" || $id
"register.html?e=" || $id
},
<xhtml:i title="Link zu diesem Eintrag" class="fa fa-link"></xhtml:i>
}
......@@ -139,6 +195,19 @@ return
$label-main/text()
},
element { "xhtml:ul" } {
(: variant :)
if(not($variant)) then () else
element { "xhtml:li" } {
attribute { "class" } { "variant" },
"Im Text: ",
element { "xhtml:ul" } {
for $var in $variant
return
element { "xhtml:li" } {
string($var)
}
}
},
(: secondary label :)
for $l in $label-alt
return
......@@ -242,7 +311,7 @@ return
</div>
<div class="panel-body">
<ul class="listOrg">
{$orgList/tei:org ! local:prepare-org(., $orgURI) }
{$orgList/tei:org ! local:prepare-org(.) }
</ul>
</div>
</div>
......@@ -255,10 +324,11 @@ return
: transforms a single tei:org element to a xhtml:li
: @since 1.0
: :)
declare function local:prepare-org($org as element(tei:org), $uri as xs:string) as element(xhtml:li) {
declare function local:prepare-org($org as element(tei:org)) as element(xhtml:li) {
let $id := $org/@xml:id
let $label-main := ($org/tei:orgName)[1]
let $label-alt := ($org/(tei:orgName, tei:idno))[position() gt 1]
let $label-alt := ($org/(tei:orgName[not(@type="variant")], tei:idno))[position() gt 1]
let $variant := $org/tei:orgName[@type="variant"]
let $note := $org/tei:note
let $bibl := $org/tei:bibl
let $links := $org/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
......@@ -285,9 +355,7 @@ return
attribute { "class" } {"registerLink"},
element { "xhtml:a" } {
attribute { "href" } {
"register.html?" ||
"r=" || $uri ||
"&amp;e=" || $id
"register.html?e=" || $id
},
<xhtml:i title="Link zu diesem Eintrag" class="fa fa-link"></xhtml:i>
}
......@@ -297,6 +365,19 @@ return
$label-main/text()
},
element { "xhtml:ul" } {
(: variant :)
if(not($variant)) then () else
element { "xhtml:li" } {
attribute { "class" } { "variant" },
"Im Text: ",
element { "xhtml:ul" } {
for $var in $variant
return
element { "xhtml:li" } {
string($var)
}
}
},
(: secondary label :)
for $l in $label-alt
return
......@@ -363,9 +444,9 @@ return
</h4>
</div>
<div class="panel-body">
<ul class="persList">
<ul class="listPerson">
{ (: $persList/tei:person|$persList/tei:personGrp :)
$persList/tei:* ! local:prepare-person(., $persURI) }
$persList/tei:* ! local:prepare-person(.) }
</ul>
</div>
</div>
......@@ -374,7 +455,7 @@ return
</div>
};
declare function local:prepare-person($pers as element(*)+, $uri as xs:string) as element(xhtml:li) {
declare function local:prepare-person($pers as element(*)+) as element(xhtml:li) {
let $label-main := $pers/tei:persName[1]
return
(: check if the item points to another entity :)
......@@ -411,7 +492,8 @@ else
(: entity :)
let $id := $pers/@xml:id
let $label-main := $pers/tei:persName[1]
let $label-alt := $pers/tei:persName[@type="variant"]
let $label-alt := $pers/tei:persName[not(@type="variant")]
let $variant := $pers/tei:persName[@type="variant"]
let $idnos := $pers/tei:idno
let $birth := $pers/tei:birth
let $death := $pers/tei:death
......@@ -454,6 +536,19 @@ else
$label-main/text()
},
element { "xhtml:ul" } {
(: variant :)
if(not($variant)) then () else
element { "xhtml:li" } {
attribute { "class" } { "variant" },
"Im Text: ",
element { "xhtml:ul" } {
for $var in $variant
return
element { "xhtml:li" } {
string($var)
}
}
},
(: secondary label :)
for $l in $label-alt
return
......@@ -599,7 +694,8 @@ then
else
(: entity :)
let $id := $place/@xml:id
let $label-alt := $place/tei:placeName[@type="variant"]
let $label-alt := $place/tei:placeName[not(@type="variant")]
let $variant := $place/tei:placeName[@type="variant"]
let $idnos := $place/tei:idno
let $note := $place/tei:note
let $bibl := $place/tei:bibl
......@@ -638,6 +734,19 @@ else
$label-main/text()
},
element { "xhtml:ul" } {
(: variant :)
if(not($variant)) then () else
element { "xhtml:li" } {
attribute { "class" } { "variant" },
"Im Text: ",
element { "xhtml:ul" } {
for $var in $variant
return
element { "xhtml:li" } {
string($var)
}
}
},
(: secondary label :)
for $l in $label-alt
return
......@@ -770,10 +879,13 @@ then
else
(: entity :)
let $id := $work/@xml:id
let $label-alt := $work/tei:name[@type="variant"]
let $label-alt := $work/tei:name[not(@type="variant")]
let $variant := $work/tei:name[@type="variant"]
let $idnos := $work/tei:idno
let $date := $work/tei:date
let $note := $work/tei:note
let $bibl := $work/tei:bibl
let $creator := $work/tei:linkGrp/tei:link[@corresp="http://purl.org/dc/terms/creator"]
let $links := $work/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
let $notebook-uris := $links ! (substring-after(./@target, "http://textgridrep.org/textgrid:") => substring(1,5) => distinct-values())
let $link-map as map() :=
......@@ -809,6 +921,19 @@ else
$label-main/text()
},
element { "xhtml:ul" } {
(: variant :)
if(not($variant)) then () else
element { "xhtml:li" } {
attribute { "class" } { "variant" },
"Im Text: ",
element { "xhtml:ul" } {
for $var in $variant
return
element { "xhtml:li" } {
string($var)
}
}
},
(: secondary label :)
for $l in $label-alt
return
......@@ -837,6 +962,23 @@ else
<xhtml:i title="Link zu externer Ressource" class="fa fa-external-link"></xhtml:i>
}
},
for $d in $date
return
element { "xhtml:li" } {
attribute { "class" } {"date"},
$d/text()
},
(: creator :)
for $c in $creator
let $target := $c/@target => substring-after(":")
return
element { "xhtml:li" } {
attribute { "class" } { "creator" },
element { "xhtml:a" } {
attribute {"href"} { "?e=" || $target },
$target
}
},
(: note :)
for $n in $note
return
......@@ -868,64 +1010,24 @@ else
local:links-event($link-map)
}
},
local:li-code($work)
local:li-code($work),
(: further entities :)
for $listPerson in $work/tei:listPerson
return
element xhtml:li {
element xhtml:ul {
attribute class { "work-listPerson" },
$listPerson/tei:person ! local:prepare-person(.)
}
},
for $listPlace in $work/tei:listPlace
return
element xhtml:li {
element xhtml:ul {
attribute class { "work-listPlace" },
$listPlace/tei:place ! local:prepare-place(.)
}
}
}
}
};
declare function fontaneregister:register($id){
let $r := request:get-parameter('r', '')
let $e := request:get-parameter('e', '')
let $agg := '253st.xml'
let $uris := doc('/db/sade-projects/textgrid/data/xml/agg/'||$agg)//ore:aggregates/substring-after(@rdf:resource, 'textgrid:')
let $meta := for $uri in $uris
where doc-available( '/db/sade-projects/textgrid/data/xml/data/' || $uri ||'.xml')
return
doc('/db/sade-projects/textgrid/data/xml/meta/'||$uri||'.xml')
let $docs := $meta//tgmd:textgridUri/tokenize(., ':|\.')[2] ! doc('/db/sade-projects/textgrid/data/xml/data/' || . ||'.xml')
let $tabs := <ul class="nav nav-tabs" style="font-size: smaller;">{
for $i at $pos in $meta
let $uri := $i//tgmd:textgridUri/tokenize(., ':|\.')[2]
where not(matches($uri,"25547|253t3"))
return
<li>
{ if(($r = $uri) or $e = doc('/db/sade-projects/textgrid/data/xml/data/' || $uri ||'.xml')//*[@xml:id]/string(@xml:id)) then attribute class {'active'} else () }
<a data-toggle="tab" href="#r{ $uri }">{$i//tgmd:title/text()}</a></li>,
(: need to hardcode stuff comming from a singe tei file: :)
<li>
{ if(($r = "r253t3-works") or ($e = doc('/db/sade-projects/textgrid/data/xml/data/253t3.xml')
//tei:body//tei:list[@type="works"]
//*[@xml:id]/string(@xml:id))) then attribute class {'active'} else ()
}
<a data-toggle="tab" href="#r253t3-works">Werke</a></li>,
<li>
{ if(($r = "r253t3-Fontane") or ($e = doc('/db/sade-projects/textgrid/data/xml/data/253t3.xml')
//tei:body//tei:list[@type="Fontane"]
//*[@xml:id]/string(@xml:id))) then attribute class {'active'} else ()
}
<a data-toggle="tab" href="#r253t3-Fontane">Fontanes Werke</a></li>,
<li>
{ if(($r = "r253t3-periodicals") or ($e = doc('/db/sade-projects/textgrid/data/xml/data/253t3.xml')
//tei:body//tei:list[@type="periodicals"]
//*[@xml:id]/string(@xml:id))) then attribute class {'active'} else ()
}
<a data-toggle="tab" href="#r253t3-periodicals">Periodika</a></li>
}</ul>
return
<div class="container">
{$tabs}
<div class="tab-content">
{ fontaneregister:events( $docs//tei:body/tei:listEvent ) }
{ fontaneregister:orgs( $docs//tei:body/tei:listOrg ) }
{ fontaneregister:persons( $docs//tei:body/tei:listPerson ) }
{ fontaneregister:places( $docs//tei:body/tei:listPlace ) }
{ fontaneregister:works( $docs//tei:body//tei:list[@type="works"] ) }
{ fontaneregister:works( $docs//tei:body//tei:list[@type="periodicals"] ) }
{ fontaneregister:works( $docs//tei:body//tei:list[@type="Fontane"] ) }
</div>
</div>
};
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