OAI-PMH XSLT library

From Koha Wiki
Jump to navigation Jump to search

This is an independent list of XSLTs. Check here for the main XSLT library on this wiki.

You can use XSLT to alter the MARCXML output by Koha's OAI-PMH server. This paqe aims to collect some tips and tricks that might be useful.

See the documentation for advice on how you configure Koha to use custom XSLT for OAI-PMH output.

Put the biblionumber in 001

  • Developer: Magnus Enger
  • Module: OAI-PMH
  • Purpose: This transformation will remove the existing 001 field, and add a new 001 field that hs the biblionumber as its value.
 <xsl:stylesheet version="1.0"
  xmlns:marc="http://www.loc.gov/MARC21/slim"
  xmlns:items="http://www.koha-community.org/items"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:package="info:srw/extension/13/package-v1.0"> 
 
  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
 
  <xsl:template match="node()|@*">
   <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
   </xsl:copy>
  </xsl:template>
 
  <!-- Remove the original versions of these fields -->
  <xsl:template match="marc:controlfield[@tag=001]"/>
 
  <!-- Add a new 001 that contains the biblionumber from 999$c -->
  <xsl:template match="marc:leader">
   <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
    <xsl:if test="not(marc:controlfield[@tag=001])">
     <xsl:text>
   </xsl:text><xsl:element name="controlfield" xmlns="http://www.loc.gov/MARC21/slim">
      <xsl:attribute name="tag">001</xsl:attribute>
      <xsl:value-of select="//marc:datafield[@tag=999]/marc:subfield[@code='c']/text()"/>
     </xsl:element>
    </xsl:if>
  </xsl:template>
 
 </xsl:stylesheet>