Bug 35305

Summary: Add XSLT for authority details page in staff interface
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: MARC Authority data supportAssignee: Fridolin Somers <fridolin.somers>
Status: Needs documenting --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: enhancement    
Priority: P5 - low CC: david, dcook, lucas, martin.renvoize, matthias.le-gac
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21330
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11083
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement enables using custom XSLT stylesheets to display authority detail pages in the staff interface. Enter a path to the custom XSLT file in the new system preference AuthorityXSLTDetailsDisplay (or use an external URL). Use placeholders for multiple custom style sheets for different languages ({langcode}) and authority types ({authtypecode}). (Note: This ability is already available for the OPAC. It was added by bug 21330 to Koha 23.05 and 22.11.07).
Version(s) released in:
24.11.00
Circulation function:
Attachments: Bug 35305: Add XSLT for authority details page in staff interface
Bug 35305: Add sample XSLT for UNIMARC authorities
Bug 35305: (follow-up) Fix identing
Bug 35305: Add XSLT for authority details page in staff interface
Bug 35305: Add sample XSLT for UNIMARC authorities details page
Bug 35305: Add sample XSLT for UNIMARC authorities details page
Bug 35305: (follow-up) Fix identing
Bug 35305: Add XSLT for authority details page in staff interface
Bug 35305: Add sample XSLT for UNIMARC authorities details page
Bug 35305: (follow-up) Fix identing
Bug 35305: Add XSLT for authority details page in staff interface
Bug 35305: Add sample XSLT for UNIMARC authorities details page
Bug 35305: (follow-up) Fix identing

Description Fridolin Somers 2023-11-09 20:04:08 UTC
Like Bug 11083 for result display, allow XSLT for details display in staff interface
Comment 1 Fridolin Somers 2023-11-09 21:29:49 UTC
Created attachment 158772 [details] [review]
Bug 35305: Add XSLT for authority details page in staff interface

This adds a new system preference 'AuthorityXSLTDetailsDisplay'.
If set, authority MARCXML will be transformed using the XSLT
at the given filename or URL.
The HTML output will be displayed in place of tabs in details page.

The syspref value can contain {langcode} and {authtypecode} which will
be replaced by the appropriate value (resp. current language and
authority type code).

Test plan:
1) Apply patch and run updatedatabase
2) Search for an authority type GEOGR_NAME and view details page
3) Verify that display is not affected yet
4) Create an XSLT file (for example in /home/koha/xslt/en/GEOGR_NAME.xsl)
5) Set 'AuthorityXSLTDetailsDisplay' syspref value to :
   /home/koha/xslt/{langcode}/{authtypecode}.xsl
6) Refresh details page
7) Verify that display matches what you expect from your XSLT
8) Go to an authority of another type
9) Verify that the default display is used

Example of a minimal XSLT:

<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:marc="http://www.loc.gov/MARC21/slim"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:template match="marc:record">
    <xsl:element name="div">
      <xsl:attribute name="class">
        <xsl:text>authority-summary</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="marc:datafield[@tag='151']/marc:subfield[@code='a']"/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
Comment 2 Fridolin Somers 2023-11-09 22:12:20 UTC
Created attachment 158775 [details] [review]
Bug 35305: Add sample XSLT for UNIMARC authorities

Also creates UNIMARCauthUtils.xsl to share templates with UNIMARCauthResults.xsl
Comment 3 Fridolin Somers 2023-11-10 02:06:15 UTC
Created attachment 158781 [details] [review]
Bug 35305: (follow-up) Fix identing
Comment 4 Matthias Le Gac 2024-01-09 15:30:24 UTC
The display match with the XSLT for type GEOGR_NAME but for the other types the default display isn't use, it's the XSLT display who is using.
Comment 5 Fridolin Somers 2024-03-14 09:00:36 UTC
(In reply to Matthias Le Gac from comment #4)
> The display match with the XSLT for type GEOGR_NAME but for the other types
> the default display isn't use, it's the XSLT display who is using.

Hi, could you explain more please ?

Using a XSLT file only for GEOGR_NAME is just an example, you may create a file per authority type or for UNIMARC use the sample file.
Comment 6 Matthias Le Gac 2024-04-11 20:56:55 UTC
(In reply to Fridolin Somers from comment #5)
> (In reply to Matthias Le Gac from comment #4)
> > The display match with the XSLT for type GEOGR_NAME but for the other types
> > the default display isn't use, it's the XSLT display who is using.
> 
> Hi, could you explain more please ?
> 
> Using a XSLT file only for GEOGR_NAME is just an example, you may create a
> file per authority type or for UNIMARC use the sample file.

What I meant was that when I go to the details of a GEOGR_NAME authority it looks just like what I specified in the XSL but it also has an impact on the details page of a PERSO_NAME authority and if I've understood the test plan correctly it shouldn't.
Comment 7 Fridolin Somers 2024-05-31 07:15:07 UTC
(In reply to Matthias Le Gac from comment #6)
> (In reply to Fridolin Somers from comment #5)
> > (In reply to Matthias Le Gac from comment #4)
> > > The display match with the XSLT for type GEOGR_NAME but for the other types
> > > the default display isn't use, it's the XSLT display who is using.
> > 
> > Hi, could you explain more please ?
> > 
> > Using a XSLT file only for GEOGR_NAME is just an example, you may create a
> > file per authority type or for UNIMARC use the sample file.
> 
> What I meant was that when I go to the details of a GEOGR_NAME authority it
> looks just like what I specified in the XSL but it also has an impact on the
> details page of a PERSO_NAME authority and if I've understood the test plan
> correctly it shouldn't.

Aaah OK, the test plan is wrong ;)
Comment 8 Fridolin Somers 2024-05-31 08:01:14 UTC
Created attachment 167302 [details] [review]
Bug 35305: Add XSLT for authority details page in staff interface

This adds a new system preference 'AuthorityXSLTDetailsDisplay'.
If set, authority MARCXML will be transformed using the XSLT
at the given filename or URL.
The HTML output will be displayed in place of tabs in details page.

The syspref value can contain {langcode} and {authtypecode} which will
be replaced by the appropriate value (resp. current language and
authority type code).

Test plan:
1) Apply patch and run updatedatabase
2) Search for an authority type GEOGR_NAME and view details page
3) Verify that display is not affected yet
4) Create an XSLT file (for example in /home/koha/xslt/en/GEOGR_NAME.xsl)
5) Set 'AuthorityXSLTDetailsDisplay' system preference to :
   /home/koha/xslt/{langcode}/{authtypecode}.xsl
6) Refresh details page
7) Verify that display matches what you expect from the XSLT
8) Set 'AuthorityXSLTDetailsDisplay' system preference to :
   <path to sources>/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCauthDetails.xsl
8) Refresh details page
9) Verify that display matches what you expect from your XSLT

Example of a minimal XSLT:

<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:marc="http://www.loc.gov/MARC21/slim"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:template match="marc:record">
    <xsl:element name="div">
      <xsl:attribute name="class">
        <xsl:text>authority-summary</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="marc:datafield[@tag='151']/marc:subfield[@code='a']"/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
Comment 9 Fridolin Somers 2024-05-31 08:01:28 UTC
Created attachment 167303 [details] [review]
Bug 35305: Add sample XSLT for UNIMARC authorities details page

Also creates UNIMARCauthUtils.xsl to share templates with UNIMARCauthResults.xsl
Comment 10 Fridolin Somers 2024-05-31 08:01:44 UTC
Created attachment 167304 [details] [review]
Bug 35305: Add sample XSLT for UNIMARC authorities details page

Also creates UNIMARCauthUtils.xsl to share templates with UNIMARCauthResults.xsl
Comment 11 Fridolin Somers 2024-05-31 08:01:54 UTC
Created attachment 167305 [details] [review]
Bug 35305: (follow-up) Fix identing
Comment 12 Fridolin Somers 2024-05-31 08:02:46 UTC
Test plan changed to test also with the sample XSLT file
Comment 13 David Nind 2024-06-03 23:36:28 UTC
Created attachment 167362 [details] [review]
Bug 35305: Add XSLT for authority details page in staff interface

This adds a new system preference 'AuthorityXSLTDetailsDisplay'.
If set, authority MARCXML will be transformed using the XSLT
at the given filename or URL.
The HTML output will be displayed in place of tabs in details page.

The syspref value can contain {langcode} and {authtypecode} which will
be replaced by the appropriate value (resp. current language and
authority type code).

Test plan:
1) Apply patch and run updatedatabase
2) Search for an authority type GEOGR_NAME and view details page
3) Verify that display is not affected yet
4) Create an XSLT file (for example in /home/koha/xslt/en/GEOGR_NAME.xsl)
5) Set 'AuthorityXSLTDetailsDisplay' system preference to :
   /home/koha/xslt/{langcode}/{authtypecode}.xsl
6) Refresh details page
7) Verify that display matches what you expect from the XSLT
8) Set 'AuthorityXSLTDetailsDisplay' system preference to :
   <path to sources>/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCauthDetails.xsl
8) Refresh details page
9) Verify that display matches what you expect from your XSLT

Example of a minimal XSLT:

<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:marc="http://www.loc.gov/MARC21/slim"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:template match="marc:record">
    <xsl:element name="div">
      <xsl:attribute name="class">
        <xsl:text>authority-summary</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="marc:datafield[@tag='151']/marc:subfield[@code='a']"/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

Signed-off-by: David Nind <david@davidnind.com>
Comment 14 David Nind 2024-06-03 23:36:31 UTC
Created attachment 167363 [details] [review]
Bug 35305: Add sample XSLT for UNIMARC authorities details page

Also creates UNIMARCauthUtils.xsl to share templates with UNIMARCauthResults.xsl

Signed-off-by: David Nind <david@davidnind.com>
Comment 15 David Nind 2024-06-03 23:36:34 UTC
Created attachment 167364 [details] [review]
Bug 35305: (follow-up) Fix identing

Signed-off-by: David Nind <david@davidnind.com>
Comment 16 Martin Renvoize (ashimema) 2024-10-28 09:21:24 UTC
Created attachment 173439 [details] [review]
Bug 35305: Add XSLT for authority details page in staff interface

This adds a new system preference 'AuthorityXSLTDetailsDisplay'.
If set, authority MARCXML will be transformed using the XSLT
at the given filename or URL.
The HTML output will be displayed in place of tabs in details page.

The syspref value can contain {langcode} and {authtypecode} which will
be replaced by the appropriate value (resp. current language and
authority type code).

Test plan:
1) Apply patch and run updatedatabase
2) Search for an authority type GEOGR_NAME and view details page
3) Verify that display is not affected yet
4) Create an XSLT file (for example in /home/koha/xslt/en/GEOGR_NAME.xsl)
5) Set 'AuthorityXSLTDetailsDisplay' system preference to :
   /home/koha/xslt/{langcode}/{authtypecode}.xsl
6) Refresh details page
7) Verify that display matches what you expect from the XSLT
8) Set 'AuthorityXSLTDetailsDisplay' system preference to :
   <path to sources>/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCauthDetails.xsl
8) Refresh details page
9) Verify that display matches what you expect from your XSLT

Example of a minimal XSLT:

<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:marc="http://www.loc.gov/MARC21/slim"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:template match="marc:record">
    <xsl:element name="div">
      <xsl:attribute name="class">
        <xsl:text>authority-summary</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="marc:datafield[@tag='151']/marc:subfield[@code='a']"/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 17 Martin Renvoize (ashimema) 2024-10-28 09:21:26 UTC
Created attachment 173440 [details] [review]
Bug 35305: Add sample XSLT for UNIMARC authorities details page

Also creates UNIMARCauthUtils.xsl to share templates with UNIMARCauthResults.xsl

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 18 Martin Renvoize (ashimema) 2024-10-28 09:21:29 UTC
Created attachment 173441 [details] [review]
Bug 35305: (follow-up) Fix identing

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Martin Renvoize (ashimema) 2024-10-28 09:22:13 UTC
I really would have liked to have see MARC21 sheets included here too but I'm not going to let that block us.

Passing QA
Comment 20 Katrin Fischer 2024-10-30 06:48:34 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 21 Lucas Gass (lukeg) 2024-11-22 21:42:15 UTC
Enhancement, no 24.05.x backport.