Skip to content

Commit

Permalink
first shot at supporting sourcesTEI
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Nov 13, 2024
1 parent cb144ec commit 0490c38
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
6 changes: 5 additions & 1 deletion modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ declare
%templates:wrap
%templates:default("max", "200")
function app:preview-teaser($node as node(), $model as map(*), $max as xs:string) as xs:string {
let $textXML := $model('doc')/tei:ab | $model('doc')//tei:body | $model('doc')//mei:annot[@type='Kurzbeschreibung'] (: letzter Fall für sources :)
let $textXML := $model('doc')/tei:ab | $model('doc')//tei:body | $model('doc')//mei:annot[@type='Kurzbeschreibung'] (: letzter Fall für MEI sources :)
return
str:shorten-TEI($textXML, number($max), $model?lang)
};
Expand Down Expand Up @@ -1914,11 +1914,15 @@ declare
else wega-util:log-to-file('warn', 'app:preview-relator-role(): Failed to reckognize role')
};

(:~
: Solely used for sources(?)
:)
declare
%templates:wrap
%templates:default("lang", "en")
function app:preview-creation($node as node(), $model as map(*), $lang as xs:string) as xs:string? {
if($model('doc')/mei:manifestation/mei:pubStmt) then string-join($model('doc')/mei:manifestation/mei:pubStmt/*, ', ')
else if($model('doc')//tei:sourceDesc/tei:biblStruct) then bibl:printCitation($model?doc//tei:sourceDesc/tei:biblStruct, <xhtml:span/>, $lang)
else if($model('doc')/mei:manifestation/mei:creation) then str:normalize-space($model('doc')/mei:manifestation/mei:creation)
else ()
};
Expand Down
4 changes: 3 additions & 1 deletion modules/bibl.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ declare function bibl:printGenericCitation($biblStruct as element(tei:biblStruct
let $authors := bibl:printCitationAuthors($biblStruct/*/tei:author, $lang)
let $title := bibl:printTitles($biblStruct/*/tei:title, $biblStruct/*/tei:edition)
let $note := bibl:printNote($biblStruct/tei:note[1], $lang)
let $imprint := bibl:printpubPlaceNYear($biblStruct/tei:monogr/tei:imprint, $biblStruct/tei:monogr/tei:edition, $lang)
return
element {$wrapperElement/name()} {
$wrapperElement/@*,
$authors,
if(exists($authors)) then ', ' else (),
$title,
bibl:idno($biblStruct/*/tei:idno),
$imprint,
$note
}
};
Expand Down Expand Up @@ -282,7 +284,7 @@ declare %private function bibl:printCitationAuthors($authors as element()*, $lan
: @param $imprint a tei:imprint element
: @return html:span element if any data is given, the empty sequence otherwise
:)
declare %private function bibl:printpubPlaceNYear($imprint as element(tei:imprint), $edition as element(tei:edition)?, $lang as xs:string) as element(xhtml:span)? {
declare %private function bibl:printpubPlaceNYear($imprint as element(tei:imprint)?, $edition as element(tei:edition)?, $lang as xs:string) as element(xhtml:span)? {
let $countPlaces := count($imprint/tei:pubPlace)
let $places :=
for $place at $count in $imprint/tei:pubPlace
Expand Down
2 changes: 1 addition & 1 deletion modules/query.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ declare function query:get-facets($collection as node()*, $facet as xs:string) a
case 'surnames' return $collection//tei:surname | $collection//tei:orgName[@type]
case 'einrichtungsform' return $collection//mei:term[@label='einrichtungsform']
case 'vorlageform' return $collection//mei:term[@label='vorlageform']
case 'asksam-cat' return $collection//mei:term[@label='asksam-cat']
case 'asksam-cat' return ($collection//mei:term[@label='asksam-cat'] | $collection//tei:term[parent::tei:keywords/@scheme='asksam-cat'])
case 'placenames' return $collection//tei:placeName[@type='reg']
case 'repository' return $collection//tei:repository/@n
case 'series' return $collection//mei:seriesStmt/mei:title[@level='s']
Expand Down
27 changes: 18 additions & 9 deletions modules/wdt.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,19 @@ declare function wdt:sources($item as item()*) as map(*) {
else false()
},
'filter' : function() as document-node()* {
$item/root()[mei:manifestation][descendant::mei:titleStmt][not(descendant::mei:annot[@type='no-ordinary-record'])]
$item/root()[mei:manifestation][descendant::mei:titleStmt][not(descendant::mei:annot[@type='no-ordinary-record'])] |
$item/root()[descendant::tei:titleStmt/tei:title = 'WeGA, Textquellen, Digitale Edition']
},
'filter-by-person' : function($personID as xs:string) as document-node()* {
if(config:is-person($personID) or config:is-org($personID)) then $item/root()/descendant::mei:persName[@codedval = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:titleStmt]/root()
else if(config:is-work($personID)) then $item/root()/descendant::mei:identifier[.=$personID][@type = 'WeGA']/root() | $item/root()/descendant::mei:relation[@target=concat('wega:', $personID)]/root()
if(config:is-person($personID) or config:is-org($personID))
then
$item/root()/descendant::mei:persName[@codedval = $personID][@role=('cmp', 'lbt', 'lyr', 'aut', 'trl')][ancestor::mei:titleStmt]/root() |
$item/root()/descendant::tei:titleStmt/tei:author[@key = $personID]/root()
else
if(config:is-work($personID))
then
$item/root()/descendant::mei:identifier[.=$personID][@type = 'WeGA']/root() | $item/root()/descendant::mei:relation[@target=concat('wega:', $personID)]/root() |
$item/root()/descendant::tei:notesStmt/tei:relatedItem[@target=concat('wega:', $personID)]/root()
else ()
},
'filter-by-date' : function($dateFrom as xs:date?, $dateTo as xs:date?) as document-node()* {
Expand All @@ -757,19 +765,20 @@ declare function wdt:sources($item as item()*) as map(*) {
$item
},
'init-collection' : function() as document-node()* {
crud:data-collection('sources')[descendant::mei:titleStmt][not(descendant::mei:annot[@type='no-ordinary-record'])]
crud:data-collection('sources')[descendant::mei:titleStmt][not(descendant::mei:annot[@type='no-ordinary-record'])] |
crud:data-collection('sources')[descendant::tei:titleStmt/tei:title = 'WeGA, Textquellen, Digitale Edition']
},
'init-sortIndex' : function() as item()* {
()
},
'title' : function($serialization as xs:string) as item()? {
let $source :=
typeswitch($item)
case xs:string return crud:doc($item)/mei:manifestation
case xs:untypedAtomic return crud:doc($item)/mei:manifestation
case document-node() return $item/mei:manifestation
default return $item/root()/mei:manifestation
let $title-element := ($source/mei:titleStmt/mei:title[not(@type)])[1]
case xs:string return crud:doc($item)/*
case xs:untypedAtomic return crud:doc($item)/*
case document-node() return $item/*
default return $item/root()/*
let $title-element := ($source/mei:titleStmt/mei:title[not(@type)], $source//tei:titleStmt/tei:title[@level='a'])[1]
return
switch($serialization)
case 'txt' return str:normalize-space(replace(string-join(str:txtFromTEI($title-element, config:guess-language(())), ''), '\s*\n+\s*(\S+)', '. $1'))
Expand Down

0 comments on commit 0490c38

Please sign in to comment.