From 281808cce6cc94e26beb6281ec44daada0a85595 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@gmail.com>
Date: Thu, 4 Sep 2014 13:12:52 -0300
Subject: [PATCH] Bug 11232: UNIMARC facet definition and updated XSL file for
DOM
This patch adds the facets definitions to the biblio-koha-indexdefs.xml, based
on what is hardcoded on C4::Koha::getFacets().
The biblio-zebra-indexdefs.xsl file for UNIMARC is generated using the usual:
xsltproc ...koha-indexdefs-to-zebra.xsl ...unimarc/biblios/biblio-koha-indexdefs.xml > \
...unimarc/biblios/biblio-zebra-indexdefs.xsl
Sponsored-by: Universidad Nacional de Cordoba
---
.../unimarc/biblios/biblio-koha-indexdefs.xml | 59 +++++++-
.../unimarc/biblios/biblio-zebra-indexdefs.xsl | 152 ++++++++++++++++++++-
2 files changed, 207 insertions(+), 4 deletions(-)
diff --git a/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml
index aeeacc5..9cd5b34 100644
--- a/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml
+++ b/etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<kohaidx:index_defs xmlns:kohaidx="http://www.koha-community.org/schemas/index-defs">
+<kohaidx:index_defs xmlns:kohaidx="http://www.koha-community.org/schemas/index-defs"
+ xmlns="http://www.koha-community.org/schemas/index-defs">
<id>marc:controlfield[@tag='001']</id>
<!--record.abs line 24: melm 001 Local-number,Local-number:n-->
<index_control_field xmlns="http://www.koha-community.org/schemas/index-defs" tag="001">
@@ -1429,4 +1430,60 @@
<target_index>totalissues:n</target_index>
<target_index>totalissues:s</target_index>
</index_subfields>
+
+ <facet tag="225" subfields="a">
+ <target_index>se:0</target_index>
+ </facet>
+ <facet tag="500" subfields="a">
+ <target_index>su-ut:0</target_index>
+ </facet>
+ <facet tag="501" subfields="a">
+ <target_index>su-ut:0</target_index>
+ </facet>
+ <facet tag="503" subfields="a">
+ <target_index>su-ut:0</target_index>
+ </facet>
+ <facet tag="600" subfields="ab">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="601" subfields="ab">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="602" subfields="a">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="604" subfields="at">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="605" subfields="a">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="606" subfields="ax">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="607" subfields="a">
+ <target_index>su-geo:0</target_index>
+ </facet>
+ <facet tag="610" subfields="a">
+ <target_index>su-to:0</target_index>
+ </facet>
+ <facet tag="700" subfields="ab">
+ <target_index>au:0</target_index>
+ </facet>
+ <facet tag="701" subfields="ab">
+ <target_index>au:0</target_index>
+ </facet>
+ <facet tag="702" subfields="ab">
+ <target_index>au:0</target_index>
+ </facet>
+ <facet tag="995" subfields="a">
+ <target_index>homebranch:0</target_index>
+ </facet>
+ <facet tag="995" subfields="b">
+ <target_index>holdingbranch:0</target_index>
+ </facet>
+ <facet tag="995" subfields="e">
+ <target_index>location:0</target_index>
+ </facet>
+
</kohaidx:index_defs>
diff --git a/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl
index 46f106d..4c28c24 100644
--- a/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl
+++ b/etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl
@@ -12,6 +12,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
<xslo:template match="text()"/>
<xslo:template match="text()" mode="index_subfields"/>
<xslo:template match="text()" mode="index_data_field"/>
+ <xslo:template match="text()" mode="index_facets"/>
<xslo:template match="text()" mode="index_heading"/>
<xslo:template match="text()" mode="index_heading_conditional"/>
<xslo:template match="text()" mode="index_match_heading"/>
@@ -27,7 +28,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
</xslo:if>
</xslo:template>
<xslo:template match="marc:record">
- <xslo:variable name="idfield" select="normalize-space(marc:controlfield[@tag='001'])"/>
+ <xslo:variable name="idfield" select="normalize-space()"/>
<z:record type="update">
<xslo:attribute name="z:id">
<xslo:value-of select="$idfield"/>
@@ -35,6 +36,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
<xslo:apply-templates/>
<xslo:apply-templates mode="index_subfields"/>
<xslo:apply-templates mode="index_data_field"/>
+ <xslo:apply-templates mode="index_facets"/>
<xslo:apply-templates mode="index_heading"/>
<xslo:apply-templates mode="index_heading_conditional"/>
<xslo:apply-templates mode="index_match_heading"/>
@@ -436,8 +438,6 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
</z:index>
</xslo:if>
</xslo:for-each>
- </xslo:template>
- <xslo:template mode="index_subfields" match="marc:datafield[@tag='101']">
<xslo:for-each select="marc:subfield">
<xslo:if test="contains('c', @code)">
<z:index name="language-original:w">
@@ -2500,6 +2500,152 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
<xslo:value-of select="normalize-space($raw_heading)"/>
</z:index>
</xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='225']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="se:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='500']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-ut:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='501']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-ut:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='503']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-ut:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='600']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='b']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='b']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='601']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='b']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='b']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='602']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='604']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='t']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='t']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='605']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='606']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='x']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='x']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='607']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-geo:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='610']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="su-to:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='700']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="au:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='b']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='b']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='701']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="au:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='b']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='b']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='702']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="au:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ <xslo:if test="marc:subfield[@code='a'] and marc:subfield[@code='b']">
+ <xslo:text>::*::</xslo:text>
+ </xslo:if>
+ <xslo:value-of select="marc:subfield[@code='b']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
+ <xslo:template mode="index_facets" match="marc:datafield[@tag='995']">
+ <xslo:if test="not(@ind1='z')">
+ <z:index name="homebranch:0">
+ <xslo:value-of select="marc:subfield[@code='a']"/>
+ </z:index>
+ <z:index name="holdingbranch:0">
+ <xslo:value-of select="marc:subfield[@code='b']"/>
+ </z:index>
+ <z:index name="location:0">
+ <xslo:value-of select="marc:subfield[@code='e']"/>
+ </z:index>
+ </xslo:if>
+ </xslo:template>
<xslo:template mode="index_all" match="text()">
<z:index name="Any:w Any:p">
<xslo:value-of select="."/>
--
1.9.1