Bugzilla – Attachment 168536 Details for
Bug 37196
Automatically add punctuation to Marc21 title fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37196: Add automatic punctuation for Marc-245
Bug-37196-Add-automatic-punctuation-for-Marc-245.patch (text/plain), 23.21 KB, created by
Alexander Wagner
on 2024-07-05 12:50:30 UTC
(
hide
)
Description:
Bug 37196: Add automatic punctuation for Marc-245
Filename:
MIME Type:
Creator:
Alexander Wagner
Created:
2024-07-05 12:50:30 UTC
Size:
23.21 KB
patch
obsolete
>From 0fbd4b19851354bc03bd08835173e8132572bec8 Mon Sep 17 00:00:00 2001 >From: Alexander Wagner <alexander.wagner@desy.de> >Date: Fri, 5 Jul 2024 14:43:49 +0200 >Subject: [PATCH] Bug 37196: Add automatic punctuation for Marc-245 >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >If the Marc Leader 18 is set to `c` or `n` add the necessary punctuation >for the Marc21 field 245 automatically. Otherwise assume the punctuation >exists and use the subfield data _as is_. The following subfields are >handled: bcfghknps > >Additionally, all title parts are enclosed in individual `<span>` tags >with proper class assignments to allow for easy styling of all the >individual parts. > >Note: some special cases (like title translations that should get an `=` >instead of a `:`) can not be handled fully automatically. > >The change applies to: >- OPAC results >- OPAC details >- intranet results >- intranet details > >Testplan: > >1. Start `ktd` >2. Check a record with additional title fields. > Examples: > - biblionumber 55: > DÃ in do Eimhir = Poems to Eimhir / Somhairle MacGill-Eain = Sorley MacLean ; edited by Christopher Whyte. > - biblionumber 58 > 'More fruitful than the soil' : army, empire and the Scottish Highlands, 1715-1815 / Andrew Mackillop. > Those should display correctly, as they hold all punctuations _in_ > the record. (Marc Leader 18 set to `a`). >3. Apply the patch >4. Call up the records again > They should display unchanged as the Leader 18 is still set to `a` > => no automatic punctuation is applied >5. Edit both records and only set the Leader 18 to either `c` or `n`. > (Note: this is _incorrect_ wrt the record semantic.) > > All punctuation chars appear _twice_ as Koha adds them automatically > as instructed even though they are there. The title display like > > - DÃ in do Eimhir = : Poems to Eimhir / / Somhairle MacGill-Eain = Sorley MacLean ; edited by Christopher Whyte. > - 'More fruitful than the soil' : : army, empire and the Scottish Highlands, 1715-1815 / / Andrew Mackillop. > > Note that for biblionumber 55 Koha displays `= :` as it is not > possible to know automatically that there should be an `=` instad of > the `:`. > >Sponsored-by: Deutsches Elektronen-Synchrotron DESY, Library >--- > .../intranet-tmpl/prog/en/xslt/MARC21_245.xsl | 97 +++++++++++++++++++ > .../en/xslt/MARC21slim2intranetDetail.xsl | 29 +----- > .../en/xslt/MARC21slim2intranetResults.xsl | 28 +----- > .../bootstrap/en/xslt/MARC21_245.xsl | 97 +++++++++++++++++++ > .../en/xslt/MARC21slim2OPACDetail.xsl | 38 ++------ > .../en/xslt/MARC21slim2OPACResults.xsl | 28 +----- > 6 files changed, 210 insertions(+), 107 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21_245.xsl > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21_245.xsl > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21_245.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21_245.xsl >new file mode 100644 >index 0000000000..b356e9c0dc >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21_245.xsl >@@ -0,0 +1,97 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ --> >+<!-- Edited: Bug 1807 [ENH] XSLT enhancements sponsored by bywater solutions 2015/01/19 WS wsalesky@gmail.com --> >+<!DOCTYPE stylesheet> >+<xsl:stylesheet version="1.0" >+ xmlns:marc="http://www.loc.gov/MARC21/slim" >+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >+ xmlns:str="http://exslt.org/strings" >+ exclude-result-prefixes="marc str"> >+ >+<xsl:template name="show-title-245"> >+ <!-- get leader 18: --> >+ <xsl:variable name="leader" select="marc:leader"/> >+ <xsl:variable name="leader18" select="substring($leader,19,1)"/> >+ <!-- if $leader18 == c or n: add punctuation --> >+ >+ <!--Bug 13381 --> >+ <xsl:if test="marc:datafield[@tag=245]"> >+ <!-- >+ <h1 class="title" property="name"> >+ --> >+ <xsl:for-each select="marc:datafield[@tag=245]"> >+ <xsl:call-template name="subfieldSelect"> >+ <xsl:with-param name="codes">a</xsl:with-param> >+ </xsl:call-template> >+ <xsl:text> </xsl:text> >+ <!-- 13381 add additional subfields--> >+ <!-- bug17625 adding f and g subfields --> >+ <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]"> >+ <xsl:choose> >+ <xsl:when test="@code='b'"> >+ <!-- 13381 Span class around subfield h so it can be suppressed via css --> >+ <span class="title_remainder"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> : </xsl:text> </xsl:if> >+ <xsl:apply-templates/> <xsl:text> </xsl:text> </span> >+ </xsl:when> >+ <xsl:when test="@code='c'"> >+ <!-- 13381 Span class around subfield c so it can be suppressed via css --> >+ <span class="title_resp_stmt"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> / </xsl:text> </xsl:if> >+ <xsl:apply-templates/> <xsl:text> </xsl:text> </span> >+ </xsl:when> >+ <xsl:when test="@code='f'"> >+ <span class="title_incldat"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>, </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='g'"> >+ <span class="title_bulkdat"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>, </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='h'"> >+ <!-- 13381 Span class around subfield h so it can be suppressed via css --> >+ <span class="title_medium"> >+ <xsl:text> </xsl:text> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>[</xsl:text> </xsl:if> >+ <xsl:apply-templates/> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>]</xsl:text> </xsl:if> >+ </span> >+ </xsl:when> >+ >+ <xsl:when test="@code='k'"> >+ <span class="title_form"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> : </xsl:text> </xsl:if> >+ <xsl:apply-templates/> <xsl:text> </xsl:text> </span> >+ </xsl:when> >+ <xsl:when test="@code='n'"> >+ <span class="title_n"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> : </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='p'"> >+ <span class="title_p"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>, </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='s'"> >+ <span class="title_s"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>. </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ >+ <xsl:otherwise> >+ <xsl:apply-templates/> >+ <xsl:text> </xsl:text> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:for-each> >+ </xsl:for-each> >+ <!-- >+ </h1> >+ --> >+ </xsl:if> >+</xsl:template> >+ >+</xsl:stylesheet> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >index 48439f3a24..f33c44dc76 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >@@ -10,6 +10,8 @@ > xmlns:str="http://exslt.org/strings" > exclude-result-prefixes="marc str"> > <xsl:import href="MARC21slimUtils.xsl"/> >+ <xsl:include href="MARC21_245.xsl"/> >+ > <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/> > <xsl:template match="/"> > <xsl:apply-templates/> >@@ -110,33 +112,10 @@ > </h1> > </xsl:if> > >- <!--Bug 13381 --> >+ <!-- Bug 37196 --> > <xsl:if test="marc:datafield[@tag=245]"> > <h1 class="title" property="name"> >- <xsl:for-each select="marc:datafield[@tag=245]"> >- <xsl:call-template name="subfieldSelect"> >- <xsl:with-param name="codes">a</xsl:with-param> >- </xsl:call-template> >- <xsl:text> </xsl:text> >- <!-- 13381 add additional subfields--> >- <!-- bz 17625 adding subfields f and g --> >- <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]"> >- <xsl:choose> >- <xsl:when test="@code='h'"> >- <!-- 13381 Span class around subfield h so it can be suppressed via css --> >- <span class="title_medium"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:when test="@code='c'"> >- <!-- 13381 Span class around subfield c so it can be suppressed via css --> >- <span class="title_resp_stmt"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:otherwise> >- <xsl:apply-templates/> >- <xsl:text> </xsl:text> >- </xsl:otherwise> >- </xsl:choose> >- </xsl:for-each> >- </xsl:for-each> >+ <xsl:call-template name="show-title-245"/> > </h1> > </xsl:if> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl >index 16a423e421..764ffd5c24 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl >@@ -7,6 +7,7 @@ > xmlns:str="http://exslt.org/strings" > exclude-result-prefixes="marc str"> > <xsl:import href="MARC21slimUtils.xsl"/> >+ <xsl:include href="MARC21_245.xsl"/> > <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/> > > <xsl:template match="/"> >@@ -308,32 +309,7 @@ > </xsl:attribute> > <xsl:attribute name="class">title</xsl:attribute> > >- <xsl:if test="marc:datafield[@tag=245]"> >- <xsl:for-each select="marc:datafield[@tag=245]"> >- <xsl:call-template name="subfieldSelect"> >- <xsl:with-param name="codes">a</xsl:with-param> >- </xsl:call-template> >- <xsl:text> </xsl:text> >- <!-- 13381 add additional subfields--> >- <!-- bz 17625 adding subfields f and g --> >- <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]"> >- <xsl:choose> >- <xsl:when test="@code='h'"> >- <!-- 13381 Span class around subfield h so it can be suppressed via css --> >- <span class="title_medium"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:when test="@code='c'"> >- <!-- 13381 Span class around subfield c so it can be suppressed via css --> >- <span class="title_resp_stmt"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:otherwise> >- <xsl:apply-templates/> >- <xsl:text> </xsl:text> >- </xsl:otherwise> >- </xsl:choose> >- </xsl:for-each> >- </xsl:for-each> >- </xsl:if> >+ <xsl:call-template name="show-title-245"/> > </a> > > <!-- Author Statement: Alternate Graphic Representation (MARC 880) --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21_245.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21_245.xsl >new file mode 100644 >index 0000000000..b356e9c0dc >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21_245.xsl >@@ -0,0 +1,97 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ --> >+<!-- Edited: Bug 1807 [ENH] XSLT enhancements sponsored by bywater solutions 2015/01/19 WS wsalesky@gmail.com --> >+<!DOCTYPE stylesheet> >+<xsl:stylesheet version="1.0" >+ xmlns:marc="http://www.loc.gov/MARC21/slim" >+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >+ xmlns:str="http://exslt.org/strings" >+ exclude-result-prefixes="marc str"> >+ >+<xsl:template name="show-title-245"> >+ <!-- get leader 18: --> >+ <xsl:variable name="leader" select="marc:leader"/> >+ <xsl:variable name="leader18" select="substring($leader,19,1)"/> >+ <!-- if $leader18 == c or n: add punctuation --> >+ >+ <!--Bug 13381 --> >+ <xsl:if test="marc:datafield[@tag=245]"> >+ <!-- >+ <h1 class="title" property="name"> >+ --> >+ <xsl:for-each select="marc:datafield[@tag=245]"> >+ <xsl:call-template name="subfieldSelect"> >+ <xsl:with-param name="codes">a</xsl:with-param> >+ </xsl:call-template> >+ <xsl:text> </xsl:text> >+ <!-- 13381 add additional subfields--> >+ <!-- bug17625 adding f and g subfields --> >+ <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]"> >+ <xsl:choose> >+ <xsl:when test="@code='b'"> >+ <!-- 13381 Span class around subfield h so it can be suppressed via css --> >+ <span class="title_remainder"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> : </xsl:text> </xsl:if> >+ <xsl:apply-templates/> <xsl:text> </xsl:text> </span> >+ </xsl:when> >+ <xsl:when test="@code='c'"> >+ <!-- 13381 Span class around subfield c so it can be suppressed via css --> >+ <span class="title_resp_stmt"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> / </xsl:text> </xsl:if> >+ <xsl:apply-templates/> <xsl:text> </xsl:text> </span> >+ </xsl:when> >+ <xsl:when test="@code='f'"> >+ <span class="title_incldat"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>, </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='g'"> >+ <span class="title_bulkdat"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>, </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='h'"> >+ <!-- 13381 Span class around subfield h so it can be suppressed via css --> >+ <span class="title_medium"> >+ <xsl:text> </xsl:text> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>[</xsl:text> </xsl:if> >+ <xsl:apply-templates/> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>]</xsl:text> </xsl:if> >+ </span> >+ </xsl:when> >+ >+ <xsl:when test="@code='k'"> >+ <span class="title_form"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> : </xsl:text> </xsl:if> >+ <xsl:apply-templates/> <xsl:text> </xsl:text> </span> >+ </xsl:when> >+ <xsl:when test="@code='n'"> >+ <span class="title_n"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text> : </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='p'"> >+ <span class="title_p"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>, </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ <xsl:when test="@code='s'"> >+ <span class="title_s"> >+ <xsl:if test="$leader18='c' or $leader18='n'"> <xsl:text>. </xsl:text> </xsl:if> >+ <xsl:apply-templates/></span> >+ </xsl:when> >+ >+ <xsl:otherwise> >+ <xsl:apply-templates/> >+ <xsl:text> </xsl:text> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:for-each> >+ </xsl:for-each> >+ <!-- >+ </h1> >+ --> >+ </xsl:if> >+</xsl:template> >+ >+</xsl:stylesheet> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >index 3fe783b615..0cbb70d59b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >@@ -8,6 +8,8 @@ > xmlns:str="http://exslt.org/strings" > exclude-result-prefixes="marc str"> > <xsl:import href="MARC21slimUtils.xsl"/> >+ <xsl:include href="MARC21_245.xsl"/> >+ > <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/> > > <xsl:template match="/"> >@@ -129,36 +131,12 @@ > </h2> > </xsl:if> > >- <!--Bug 13381 --> >- <xsl:if test="marc:datafield[@tag=245]"> >- <h1 class="title" property="name"> >- <xsl:for-each select="marc:datafield[@tag=245]"> >- <xsl:call-template name="subfieldSelect"> >- <xsl:with-param name="codes">a</xsl:with-param> >- </xsl:call-template> >- <xsl:text> </xsl:text> >- <!-- 13381 add additional subfields--> >- <!-- bug17625 adding f and g subfields --> >- <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]"> >- <xsl:choose> >- <xsl:when test="@code='h'"> >- <!-- 13381 Span class around subfield h so it can be suppressed via css --> >- <span class="title_medium"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:when test="@code='c'"> >- <!-- 13381 Span class around subfield c so it can be suppressed via css --> >- <span class="title_resp_stmt"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:otherwise> >- <xsl:apply-templates/> >- <xsl:text> </xsl:text> >- </xsl:otherwise> >- </xsl:choose> >- </xsl:for-each> >- </xsl:for-each> >- </h1> >- </xsl:if> >- >+ <!-- Bug 37196 --> >+ <xsl:if test="marc:datafield[@tag=245]"> >+ <h1 class="title" property="name"> >+ <xsl:call-template name="show-title-245"/> >+ </h1> >+ </xsl:if> > > <!-- Author Statement: Alternate Graphic Representation (MARC 880) --> > <xsl:if test="$display880"> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl >index c2ebe9c7d9..9cdbce68a8 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl >@@ -9,6 +9,7 @@ > xmlns:str="http://exslt.org/strings" > exclude-result-prefixes="marc items str" extension-element-prefixes="exsl"> > <xsl:import href="MARC21slimUtils.xsl"/> >+ <xsl:include href="MARC21_245.xsl"/> > <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/> > > <xsl:key name="item-by-status" match="items:item" use="items:status"/> >@@ -431,32 +432,7 @@ > </xsl:attribute> > <xsl:attribute name="class"><xsl:value-of select="'title'" /></xsl:attribute> > >- <xsl:if test="marc:datafield[@tag=245]"> >- <xsl:for-each select="marc:datafield[@tag=245]"> >- <xsl:call-template name="subfieldSelect"> >- <xsl:with-param name="codes">a</xsl:with-param> >- </xsl:call-template> >- <xsl:text> </xsl:text> >- <!-- 13381 add additional subfields--> >- <!-- bz 17625 adding subfields f and g --> >- <xsl:for-each select="marc:subfield[contains('bcfghknps', @code)]"> >- <xsl:choose> >- <xsl:when test="@code='h'"> >- <!-- 13381 Span class around subfield h so it can be suppressed via css --> >- <span class="title_medium"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:when test="@code='c'"> >- <!-- 13381 Span class around subfield c so it can be suppressed via css --> >- <span class="title_resp_stmt"><xsl:apply-templates/> <xsl:text> </xsl:text> </span> >- </xsl:when> >- <xsl:otherwise> >- <xsl:apply-templates/> >- <xsl:text> </xsl:text> >- </xsl:otherwise> >- </xsl:choose> >- </xsl:for-each> >- </xsl:for-each> >- </xsl:if> >+ <xsl:call-template name="show-title-245"/> > </a> > > <!-- OpenURL --> >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37196
:
168536
|
169139
|
174381