Skip to content

Commit

Permalink
Merge pull request #465 from Edirom/issue-464
Browse files Browse the repository at this point in the history
output idno information for bibliographic records
  • Loading branch information
peterstadler committed May 27, 2024
2 parents 41bc77f + f49ff0c commit 0bebbab
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
18 changes: 17 additions & 1 deletion modules/bibl.xqm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xquery version "3.0" encoding "UTF-8";
xquery version "3.1" encoding "UTF-8";

module namespace bibl="http://xquery.weber-gesamtausgabe.de/modules/bibl";

Expand Down Expand Up @@ -62,6 +62,7 @@ declare function bibl:printGenericCitation($biblStruct as element(tei:biblStruct
$authors,
if(exists($authors)) then ', ' else (),
$title,
bibl:idno($biblStruct/*/tei:idno),
$note
}
};
Expand Down Expand Up @@ -95,6 +96,7 @@ declare function bibl:printBookCitation($biblStruct as element(tei:biblStruct),
if($biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = 'vol']) then bibl:print-single-biblScope-unit((), $biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = 'vol'], $lang) || ', ' else (),
$pubPlaceNYear,
if($biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = 'pp']) then bibl:print-single-biblScope-unit(', ', $biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = 'pp'], $lang) else (),
bibl:idno($biblStruct/tei:monogr/tei:idno),
$note
}
};
Expand All @@ -121,6 +123,7 @@ declare function bibl:printArticleCitation($biblStruct as element(tei:biblStruct
if($articleTitle) then (bibl:printTitles($articleTitle, ()), ', in: ') else (),
$journalCitation/xhtml:span,
$journalCitation/text(),
bibl:idno($biblStruct/tei:analytic/tei:idno),
$note
}
};
Expand Down Expand Up @@ -153,6 +156,7 @@ declare function bibl:printIncollectionCitation($biblStruct as element(tei:biblS
if(exists($series)) then (' ',<xhtml:span>({$series})</xhtml:span>) else (),
if(exists($pubPlaceNYear)) then (', ', $pubPlaceNYear) else(),
if($biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = 'pp']) then concat(', ', lang:get-language-string('pp', $lang), '&#160;', bibl:normalize-hyphen($biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = 'pp'])) else (),
bibl:idno($biblStruct/tei:analytic/tei:idno),
$note
}
};
Expand Down Expand Up @@ -358,3 +362,15 @@ declare %private function bibl:printNote($notes as element(tei:note)*, $lang as
declare %private function bibl:normalize-hyphen($biblScope as element(tei:biblScope)) as xs:string {
replace($biblScope, '-', '–')
};

(:~
: Process idno elements to output DOIs and alike
:)
declare %private function bibl:idno($idnos as element(tei:idno)*) as element(xhtml:span)* {
for $idno in $idnos
return
switch($idno/@type)
case 'DOI' return <xhtml:span class="idno_DOI">, DOI: <xhtml:a href="{concat('https://doi.org/', normalize-space($idno))}">{$idno => data(), ' '} <i class="fa fa-external-link" aria-hidden="true"></i></xhtml:a></xhtml:span>
case 'WeGA' return <xhtml:span class="idno_WeGA">, Volltext verfügbar unter <xhtml:a href="{config:permalink($idno)}">{$idno => data()}</xhtml:a></xhtml:span>
default return <xhtml:span class="{concat('idno_', $idno/@type)}">, online unter <xhtml:a href="{$idno => data()}">{$idno => data(), ' '} <i class="fa fa-external-link" aria-hidden="true"></i></xhtml:a></xhtml:span>
};
26 changes: 25 additions & 1 deletion testing/xqsuite/biblio-tests.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare
%test:args('A111355') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='title'>Enchanted Wanderer. The Life of Carl Maria von Weber</xhtml:span>")
%test:args('A111377') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='title'>Die Beziehungen Carl Maria v. Webers zu thüringischen Musikern</xhtml:span>")
%test:args('A111038') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='title'>„… wer Flöte bläst, kauft doch allemahl von meinen Werken“. Anton Bernhard Fürstenaus Briefkontakte zum Verlag B. Schott’s Söhne zwischen 1819 und 1825</xhtml:span>")
%test:args('A111057') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='title'>Die Rezeption von Carl Maria von Webers „Der Freischütz“ als deutsche Nationaloper. <xhtml:a href='https://doi.org/10.25365/thesis.25680'>Diplomarbeit <xhtml:i class='fa fa-external-link' aria-hidden='true'/></xhtml:a> zum Magistra der Philosophie (Mag. phil.) an der Universität Wien</xhtml:span>")
%test:args('A111057') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='title'>Die Rezeption von Carl Maria von Webers „Der Freischütz“ als deutsche Nationaloper. Diplomarbeit zum Magistra der Philosophie (Mag. phil.) an der Universität Wien</xhtml:span>")
%test:args('A111055') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='title'>Das <xhtml:span class='tei_hi_italic'>Freischütz</xhtml:span>-Libretto: Quellensituation und intertextuelle Referenzen</xhtml:span>")
function bt:test-title($a as xs:string) as element()+ {
let $doc := crud:doc($a)
Expand Down Expand Up @@ -68,3 +68,27 @@ declare
return
bibl:printCitation($doc/tei:biblStruct, <xhtml:div/>, 'de')//xhtml:span[@class='placeNYear']
};

declare
%test:args('A111057') %test:assertXPath("$result//xhtml:span[@class='idno_DOI'] and $result//xhtml:span[@class='title'] and $result//xhtml:span[@class='author'] and $result//xhtml:span[@class='placeNYear']")
function bt:test-printBookCitation($a as xs:string) as element() {
let $doc := crud:doc($a)
return
bibl:printBookCitation($doc/tei:biblStruct, <xhtml:div/>, 'de')
};

declare
%test:args('A112915') %test:assertXPath("$result//xhtml:span[@class='idno_URI'] and $result//xhtml:span[@class='title'] and $result//xhtml:span[@class='author'] and $result//xhtml:span[@class='journalTitle']")
function bt:test-printArticleCitation($a as xs:string) as element() {
let $doc := crud:doc($a)
return
bibl:printArticleCitation($doc/tei:biblStruct, <xhtml:div/>, 'de')
};

declare
%test:args('A113081') %test:assertXPath("$result//xhtml:span[@class='idno_DOI'] and $result//xhtml:span[@class='title'] and $result//xhtml:span[@class='author'] and $result//xhtml:span[@class='collectionTitle'] and $result//xhtml:span[@class='editor'] and $result//xhtml:span[@class='placeNYear'] and $result//xhtml:span[@class='seriesTitle']")
function bt:test-printIncollectionCitation($a as xs:string) as element() {
let $doc := crud:doc($a)
return
bibl:printIncollectionCitation($doc/tei:biblStruct, <xhtml:div/>, 'de')
};

0 comments on commit 0bebbab

Please sign in to comment.