Skip to content

Commit

Permalink
Merge pull request #478 from Edirom/issue-470
Browse files Browse the repository at this point in the history
process editors as "idem" if identical with authors
  • Loading branch information
peterstadler authored Jul 1, 2024
2 parents f58f6f0 + 3ee2368 commit 528c877
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 8 deletions.
3 changes: 3 additions & 0 deletions catalogues/dictionary_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@
<entry xml:id="leaf">Bl.</entry>
<entry xml:id="issue">Heft</entry>
<entry xml:id="edBy">hg. von</entry>
<entry xml:id="edByIdemM">dems.</entry>
<entry xml:id="edByIdemF">ders.</entry>
<entry xml:id="edByIdemPl">dens.</entry>
<entry xml:id="ed">Hg.</entry>
<entry xml:id="detailsAvailable">Details verfügbar</entry>
<entry xml:id="emptyResultSet">Zu dieser Filtereinstellung wurden keine Einträge gefunden.</entry>
Expand Down
3 changes: 3 additions & 0 deletions catalogues/dictionary_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@
<entry xml:id="leaf">f</entry>
<entry xml:id="issue">issue</entry>
<entry xml:id="edBy">ed. by</entry>
<entry xml:id="edByIdemM">idem</entry>
<entry xml:id="edByIdemF">idem</entry>
<entry xml:id="edByIdemPl">idem</entry>
<entry xml:id="ed">Ed.</entry>
<entry xml:id="detailsAvailable">more details</entry>
<entry xml:id="emptyResultSet">No entries found for this filter setting.</entry>
Expand Down
43 changes: 40 additions & 3 deletions modules/bibl.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare namespace mei="http://www.music-encoding.org/ns/mei";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare namespace exist="http://exist.sourceforge.net/NS/exist";
import module namespace config="http://xquery.weber-gesamtausgabe.de/modules/config" at "config.xqm";
import module namespace crud="http://xquery.weber-gesamtausgabe.de/modules/crud" at "crud.xqm";
import module namespace lang="http://xquery.weber-gesamtausgabe.de/modules/lang" at "lang.xqm";
import module namespace str="http://xquery.weber-gesamtausgabe.de/modules/str" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/str.xqm";
import module namespace wega-util="http://xquery.weber-gesamtausgabe.de/modules/wega-util" at "wega-util.xqm";
Expand Down Expand Up @@ -91,7 +92,7 @@ declare function bibl:printBookCitation($biblStruct as element(tei:biblStruct),
else if(exists($editors)) then ($editors, concat(' (', lang:get-language-string('ed', $lang), '), '))
else (),
$title,
if(exists($editors) and exists($authors)) then (concat(', ', lang:get-language-string('edBy', $lang), ' '), $editors) else (),
if(exists($editors) and exists($authors)) then bibl:edited-by($biblStruct, $lang) else (),
if(exists($series)) then (' (', $series, '), ') else ', ',
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,
Expand Down Expand Up @@ -139,7 +140,6 @@ declare function bibl:printArticleCitation($biblStruct as element(tei:biblStruct
:)
declare function bibl:printIncollectionCitation($biblStruct as element(tei:biblStruct), $wrapperElement as element(), $lang as xs:string) as element() {
let $authors := bibl:printCitationAuthors($biblStruct/tei:analytic/tei:author, $lang)
let $editor := bibl:printCitationAuthors($biblStruct/tei:monogr/tei:editor, $lang)
let $articleTitle := bibl:printTitles($biblStruct/tei:analytic/tei:title, ())
let $bookTitle := <xhtml:span class="collectionTitle">{bibl:printTitles($biblStruct/tei:monogr/tei:title, $biblStruct/tei:monogr/tei:edition)/node()}</xhtml:span>
let $pubPlaceNYear := bibl:printpubPlaceNYear($biblStruct/tei:monogr/tei:imprint, $biblStruct/tei:monogr/tei:edition, $lang)
Expand All @@ -152,7 +152,7 @@ declare function bibl:printIncollectionCitation($biblStruct as element(tei:biblS
$articleTitle,
', in: ',
$bookTitle,
if(exists($editor)) then (concat(', ', lang:get-language-string('edBy', $lang), ' '), $editor) else (),
bibl:edited-by($biblStruct, $lang),
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 (),
Expand Down Expand Up @@ -374,3 +374,40 @@ declare %private function bibl:idno($idnos as element(tei:idno)*) as element(xht
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>
};

(:~
: Process editors
: Helper function for bibl:printBookCitation and bibl:printIncollectionCitation
:)
declare %private function bibl:edited-by($biblStruct as element(tei:biblStruct), $lang as xs:string) as item()* {
let $editors := bibl:printCitationAuthors($biblStruct/tei:monogr/tei:editor, $lang)
let $ders as xs:boolean :=
count($biblStruct/tei:monogr/tei:editor) eq 1 and
count($biblStruct/tei:analytic/tei:author) eq 1 and
exists($biblStruct/tei:monogr/tei:editor/@key) and
exists($biblStruct/tei:analytic/tei:author/@key) and
$biblStruct/tei:monogr/tei:editor/@key = $biblStruct/tei:analytic/tei:author/@key
let $dens as xs:boolean :=
count($biblStruct/tei:monogr/tei:editor) gt 1 and
count($biblStruct/tei:analytic/tei:author) gt 1 and
count($biblStruct/tei:analytic/tei:author) eq count($biblStruct/tei:monogr/tei:editor) and
(every $i in ($biblStruct/tei:analytic/tei:author | $biblStruct/tei:monogr/tei:editor) satisfies $i/@key) and
(every $i in $biblStruct/tei:analytic/tei:author/@key satisfies $i = $biblStruct/tei:monogr/tei:editor/@key)
let $sex :=
if($ders)
then crud:doc($biblStruct/tei:monogr/tei:editor/@key)//tei:sex
else ()
return
if(exists($editors))
then
if($dens)
then (concat(', ', lang:get-language-string('edBy', $lang), ' '), <xhtml:span class="editor">{lang:get-language-string('edByIdemPl', $lang)}</xhtml:span>)
else
if($sex = 'm')
then (concat(', ', lang:get-language-string('edBy', $lang), ' '), <xhtml:span class="editor">{lang:get-language-string('edByIdemM', $lang)}</xhtml:span>)
else
if($sex = 'f')
then (concat(', ', lang:get-language-string('edBy', $lang), ' '), <xhtml:span class="editor">{lang:get-language-string('edByIdemF', $lang)}</xhtml:span>)
else (concat(', ', lang:get-language-string('edBy', $lang), ' '), $editors)
else ()
};
19 changes: 19 additions & 0 deletions testing/xqsuite/biblio-tests.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ declare

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']")
%test:args('A112745') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml' class='book'><xhtml:span class='author'>Ferdinand Zehentreiter</xhtml:span>, <xhtml:span class='title'>„Dem folgt deutscher Gesang“. Adornos Physiognomik des <span xmlns='http://www.w3.org/1999/xhtml' class='tei_hi_italic'>Freischütz</span></xhtml:span> (<xhtml:span><xhtml:span class='seriesTitle'>Caprices</xhtml:span>, Bd.&#160;1</xhtml:span>), <xhtml:span class='placeNYear'>Hofheim am Taunus 2019</xhtml:span></xhtml:div>")
%test:args('A110124') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml' class='book'><xhtml:span class='editor'>Joachim Veit</xhtml:span>, <xhtml:span class='editor'>Eveline Bartlitz</xhtml:span> und <xhtml:span class='editor'>Dagmar Beck</xhtml:span> (Hg.), <xhtml:span class='title'>„...die Hoffnung muß das Beste thun.“ Die Emser Briefe Carl Maria von Webers an seine Frau</xhtml:span>, <xhtml:span class='placeNYear'>München 2003</xhtml:span></xhtml:div>")
%test:args('A111337') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml' class='book'><xhtml:span class='author'>August Apel</xhtml:span>, <xhtml:span class='title'>Die Freischützsage und ihre Wandlungen. Vom Gespensterbuch zur Oper<xhtml:span class='edition'>, Neuausgabe der Freischützsage aus dem Gespensterbuch</xhtml:span></xhtml:span>, hg. von <xhtml:span class='editor'>Otto Daube</xhtml:span>, <xhtml:span class='placeNYear'>Detmold 1941</xhtml:span></xhtml:div>")
function bt:test-printBookCitation($a as xs:string) as element() {
let $doc := crud:doc($a)
return
Expand All @@ -79,6 +82,7 @@ declare

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']")
%test:args('A112660') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml'><xhtml:span class='author'>Kurt Mey</xhtml:span>, <xhtml:span class='title'>Richard Wagners Webertrauermarsch</xhtml:span>, in: <xhtml:span class='journalTitle'>Die Musik. Illustrierte Halbmonatsschrift</xhtml:span>, Jg.&#160;6 (1907), Heft&#160;12, S.&#160;331–336</xhtml:div>")
function bt:test-printArticleCitation($a as xs:string) as element() {
let $doc := crud:doc($a)
return
Expand Down Expand Up @@ -110,8 +114,23 @@ declare

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']")
%test:args('A110779') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml'><xhtml:span class='author'>Joachim Veit</xhtml:span>, <xhtml:span class='title'>Zum Formproblem in den Kopfsätzen der Sinfonien Carl Maria von Webers</xhtml:span>, in: <xhtml:span class='collectionTitle'>Festschrift Arno Forchert zum 60. Gebrutstag</xhtml:span>, hg. von <xhtml:span class='editor'>Gerhard Allroggen</xhtml:span> und <xhtml:span class='editor'>Detlef Altenburg</xhtml:span>, <xhtml:span class='placeNYear'>Kassel 1986</xhtml:span>, S.&#160;184–199</xhtml:div>")
%test:args('A112665') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml'><xhtml:span class='author'>Romy Donath</xhtml:span>, <xhtml:span class='title'>Deutsche Nationaloper oder romantische Gruselstory?</xhtml:span>, in: <xhtml:span class='collectionTitle'>200 Jahre Freischütz. Festschrift des Carl-Maria-von-Weber-Museums</xhtml:span>, hg. von <xhtml:span class='editor'>ders.</xhtml:span>, <xhtml:span class='placeNYear'>Niederjahna 2021</xhtml:span>, S.&#160;7–29</xhtml:div>")
%test:args('A111266') %test:assertEquals("<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml'><xhtml:span class='author'>Günter Haußwald</xhtml:span>, <xhtml:span class='title'>Zur Dramaturgie des „Freischütz“</xhtml:span>, in: <xhtml:span class='collectionTitle'>Carl Maria von Weber. Eine Gedenkschrift</xhtml:span>, hg. von <xhtml:span class='editor'>dems.</xhtml:span>, <xhtml:span class='placeNYear'>Dresden 1951</xhtml:span>, S.&#160;139–151</xhtml:div>")
function bt:test-printIncollectionCitation($a as xs:string) as element() {
let $doc := crud:doc($a)
return
bibl:printIncollectionCitation($doc/tei:biblStruct, <xhtml:div/>, 'de')
};

declare
%test:args('A110779') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>Gerhard Allroggen</xhtml:span>", "<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>Detlef Altenburg</xhtml:span>")
%test:args('A110211') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>Bernhard R. Appel</xhtml:span>", "<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>Joachim Veit</xhtml:span>")
%test:args('A112665') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>ders.</xhtml:span>")
%test:args('A111266') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>dems.</xhtml:span>")
%test:args('A110035') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='editor'>dens.</xhtml:span>")
function bt:test-ed-by($a as xs:string) as element()* {
let $doc := crud:doc($a)
return
bibl:printIncollectionCitation($doc/tei:biblStruct, <xhtml:div/>, 'de')//xhtml:span[@class='editor']
};
6 changes: 1 addition & 5 deletions testing/xqsuite/run-unit-tests.xql
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ xquery version "3.1";
(: the following line must be added to each of the modules that include unit tests :)
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";

(:import module namespace wust="http://xquery.weber-gesamtausgabe.de/modules/wega-util-shared-tests" at "wega-util-shared-tests.xqm";
import module namespace dt="http://xquery.weber-gesamtausgabe.de/modules/date-tests" at "date-tests.xqm";
import module namespace st="http://xquery.weber-gesamtausgabe.de/modules/str-tests" at "str-tests.xqm";
import module namespace mt="http://xquery.weber-gesamtausgabe.de/modules/math-tests" at "math-tests.xqm";
import module namespace geot="http://xquery.weber-gesamtausgabe.de/modules/geo-tests" at "geo-tests.xqm";:)
import module namespace bt="http://weber-gesamtausgabe.de/xqsuite/biblio-tests" at "biblio-tests.xqm";

(: the test:suite() function will run all the test-annotated functions in the module whose namespace URI you provide :)
test:suite((
Expand Down

0 comments on commit 528c877

Please sign in to comment.