OAI-PMH XSLT library

From Koha Wiki

Jump to: navigation, search
Home > Documentation
Home > Documentation
Home > Documentation
Koha > Library
Tips & Tricks > Tips & Tricks/Customising Notices and Slips > Tips & Tricks

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

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>

 <xsl:template match="marc:controlfield[@tag=001]"/>

 <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>
Personal tools