Skip to content

fix bibl:printIncollectionCitation()#3` to accept multiple biblScopes#582

Open
SteffenAstheimer wants to merge 2 commits intodevelopfrom
fix-bibl-printIncollectionCitation#3
Open

fix bibl:printIncollectionCitation()#3` to accept multiple biblScopes#582
SteffenAstheimer wants to merge 2 commits intodevelopfrom
fix-bibl-printIncollectionCitation#3

Conversation

@SteffenAstheimer
Copy link
Contributor

This fixes the cardinality errors described in issue #581 and improves the rendering of <biblScope> elements for writings, specifically by accepting multiple of those and sorting them by 'vol', 'jg', 'issue', and 'nr'.

I tested by locally HTTP probing all writings and got zero bad requests. I also manually tested all writings, that use the formerly malfunctioning bibl:printIncollectionCitation()#3 function.

collection('/db/apps/WeGA-data/writings')//tei:biblStruct[
    tei:analytic
    and tei:monogr/tei:title[@level='m']
    and count(.//tei:imprint/tei:biblScope[not(@unit=('pp','col','fol'))]) gt 1
]

Also checked and updated the unit tests meanwhile.

The file A110745 was actually poorly written and changed in the last weeks, so I deleted this test without replacement, as there was no adequate file to add upon the first test.
@SteffenAstheimer SteffenAstheimer added this to the Release 4.14 milestone Jan 28, 2026
@SteffenAstheimer SteffenAstheimer self-assigned this Jan 28, 2026
@SteffenAstheimer SteffenAstheimer added bug tech:XQuery docType:writings bugs and features related to the display of writings labels Jan 28, 2026
Copy link
Member

@peterstadler peterstadler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a test for one of the failing IDs (A031324, A031792, A031596)?
Or are these cases already covered?

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 $biblScope := $biblStruct/tei:monogr/tei:imprint/tei:biblScope[not(@unit = 'pp' or @unit = 'col')]
let $biblScopes := for $unit in ('vol', 'jg', 'issue', 'nr') return $biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = $unit]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a for loop since the = operator works on sequences, see e.g. https://www.data2type.de/xml-xslt-xslfo/xpath/referenz/operatoren/vergleichsausdruecke

Suggested change
let $biblScopes := for $unit in ('vol', 'jg', 'issue', 'nr') return $biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = $unit]
let $biblScopes := $biblStruct/tei:monogr/tei:imprint/tei:biblScope[@unit = ('vol', 'jg', 'issue', 'nr')]

', in: ',
$bookTitle,
if ($biblScope) then (<xhtml:span class="{$biblScope/@unit}">{bibl:print-single-biblScope-unit(', ', $biblScope, $lang)}</xhtml:span>) else (),
if(exists($biblScopes)) then for $biblScope in $biblScopes return (<xhtml:span class="{string($biblScope/@unit)}">{bibl:print-single-biblScope-unit(', ', $biblScope, $lang)}</xhtml:span>) else (),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can skip the test here since the for loop won't do anything for an empty sequence anyway:

Suggested change
if(exists($biblScopes)) then for $biblScope in $biblScopes return (<xhtml:span class="{string($biblScope/@unit)}">{bibl:print-single-biblScope-unit(', ', $biblScope, $lang)}</xhtml:span>) else (),
for $biblScope in $biblScopes return (<xhtml:span class="{string($biblScope/@unit)}">{bibl:print-single-biblScope-unit(', ', $biblScope, $lang)}</xhtml:span>),

@@ -41,7 +41,6 @@ declare

declare
%test:args('A111038') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='collectionTitle'>„Ei, dem alten Herrn zoll’ ich Achtung gern’“. Festschrift für Joachim Veit zum 60. Geburtstag</xhtml:span>")
%test:args('A110745') %test:assertEquals("<xhtml:span xmlns:xhtml='http://www.w3.org/1999/xhtml' class='collectionTitle'>Genie, Irrsinn und Ruhm. Die Komponisten<xhtml:span class='edition'>, 7. völlig neu bearb. Auflage</xhtml:span></xhtml:span>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see that this file has changed from "inbook" to "book" so there's no collectionTitle anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug docType:writings bugs and features related to the display of writings tech:XQuery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cardinality error for biblio in writings of type incollection

2 participants