Adds a stylesheet for Zebra to do an on-the-fly conversion of the

Koha 952 item fields to the MARC21 standard 852 location fields:

Please add the following to the documentation in a section explaining
the setup of a SRU/Z39.50 server. You can also pull info from:

http://wiki.koha.org/doku.php?id=en:development:z3950sru

Modifying Output of Your Records On-the-fly

Koha supports modifying the output of your MARC records for public-facing
Z39.50 and SRU servers. You can set up custom mappings to convert fields such
as 952 (Koha items) to 852 (MARC21 location fields). For example here would
be a popular mapping:
Name:		Koha Field		Mapping in MARC21
---------------------------
Location: 	952 $b => 		852 $b
Barcode: 	952 $p => 		852 $p
Price: 		952 $v => 		852 $r
Item type: 	952 $y => 		852 $w
Notes:		952 $z => 		852 $z

This would make the output from the SRU server suitable for a
resource sharing network that used the above convention for location
information. To add this configuration to your Zebra, add the following
block of code in the koha-conf.xml in the <retrievalinfo> area:

<retrieval syntax="xml" name="marc21location">
         <backend syntax="usmarc" name="F">
           <marc inputformat="marc" outputformat="marcxml"
                 inputcharset="utf-8"/>
           <xslt stylesheet="/path/to/koha/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim9522852.xsl"/>
         </backend>
 </retrieval>

The retrieval set name (in this case, marc21location) is arbitrary and
should be set as required by your resource sharing network, so long as it won't
conflict with internal usage within Koha itself. It's the retrieval set name
that is used to trigger the server to respond and parse the record through the
stylesheet and apply the mappings.

In SRU, this is set as follows:

http://example.com:210/biblios?version=1.1&operation=searchRetrieve&query=it&startRecord=1&maximumRecords=20&recordSchema=marc21location

In Z39.50 it's the elementset name construct.
This commit is contained in:
Joshua Ferraro 2008-07-21 18:09:27 -05:00
parent 72143ef63e
commit 4c4f815a34

View file

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ -->
<xsl:stylesheet version="1.0"
xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="marc">
<xsl:import href="MARC21slimUtils.xsl"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="marc:record">
<xsl:variable name="leader" select="marc:leader"/>
<xsl:variable name="controlField001" select="marc:controlfield[@tag=001]"/>
<xsl:variable name="controlField003" select="marc:controlfield[@tag=003]"/>
<xsl:variable name="controlField005" select="marc:controlfield[@tag=005]"/>
<xsl:variable name="controlField006" select="marc:controlfield[@tag=006]"/>
<xsl:variable name="controlField007" select="marc:controlfield[@tag=007]"/>
<xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
<record>
<xsl:if test="$leader"><leader><xsl:value-of select="$leader"/></leader></xsl:if>
<xsl:if test="$controlField001">
<controlfield><xsl:attribute name="tag">001</xsl:attribute><xsl:value-of select="$controlField001"/></controlfield>
</xsl:if>
<xsl:if test="$controlField003">
<controlfield><xsl:attribute name="tag">003</xsl:attribute><xsl:value-of select="$controlField003"/></controlfield>
</xsl:if>
<xsl:if test="$controlField005">
<controlfield><xsl:attribute name="tag">005</xsl:attribute><xsl:value-of select="$controlField005"/></controlfield>
</xsl:if>
<xsl:if test="$controlField006">
<controlfield><xsl:attribute name="tag">006</xsl:attribute><xsl:value-of select="$controlField006"/></controlfield>
</xsl:if>
<xsl:if test="$controlField007">
<controlfield><xsl:attribute name="tag">007</xsl:attribute><xsl:value-of select="$controlField007"/></controlfield>
</xsl:if>
<xsl:if test="$controlField008">
<controlfield><xsl:attribute name="tag">008</xsl:attribute><xsl:value-of select="$controlField008"/></controlfield>
</xsl:if>
<xsl:for-each select="marc:datafield">
<xsl:choose>
<xsl:when test="@tag=952">
<datafield tag="852" ind1=" " ind2=" ">
<xsl:for-each select="marc:subfield[@code='b']">
<subfield><xsl:attribute name="code">b</xsl:attribute>
<xsl:value-of select="."/>
</subfield>
</xsl:for-each>
<xsl:for-each select="marc:subfield[@code='p']">
<subfield><xsl:attribute name="code">p</xsl:attribute>
<xsl:value-of select="."/>
</subfield>
</xsl:for-each>
<xsl:for-each select="marc:subfield[@code='v']">
<subfield><xsl:attribute name="code">r</xsl:attribute>
<xsl:value-of select="."/>
</subfield>
</xsl:for-each>
<xsl:for-each select="marc:subfield[@code='y']">
<subfield><xsl:attribute name="code">w</xsl:attribute>
<xsl:value-of select="."/>
</subfield>
</xsl:for-each>
<xsl:for-each select="marc:subfield[@code='z']">
<subfield><xsl:attribute name="code">z</xsl:attribute>
<xsl:value-of select="."/>
</subfield>
</xsl:for-each>
</datafield>
</xsl:when>
<xsl:otherwise>
<datafield>
<xsl:attribute name="tag"><xsl:value-of select="@tag"/></xsl:attribute>
<xsl:attribute name="ind1"><xsl:value-of select="@ind1"/></xsl:attribute>
<xsl:attribute name="ind2"><xsl:value-of select="@ind2"/></xsl:attribute>
<xsl:for-each select="marc:subfield">
<subfield><xsl:attribute name="code"><xsl:value-of select="@code"/></xsl:attribute><xsl:value-of select="."/></subfield>
</xsl:for-each>
</datafield>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</record>
</xsl:template>
</xsl:stylesheet>