Bugzilla – Attachment 32352 Details for
Bug 11232
Retrieve facets from Zebra
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 11232: Add new syntax for facets definition on koha-indexdefs-to-zebra.xsl
PASSED-QA-Bug-11232-Add-new-syntax-for-facets-defi.patch (text/plain), 11.63 KB, created by
Katrin Fischer
on 2014-10-15 15:29:49 UTC
(
hide
)
Description:
[PASSED QA] Bug 11232: Add new syntax for facets definition on koha-indexdefs-to-zebra.xsl
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-10-15 15:29:49 UTC
Size:
11.63 KB
patch
obsolete
>From 5057b77a59ce198e202f3dd1dcc98db08032bb11 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Thu, 4 Sep 2014 13:11:07 -0300 >Subject: [PATCH] [PASSED QA] Bug 11232: Add new syntax for facets definition > on koha-indexdefs-to-zebra.xsl > >This patch changes koha-indexdefs-to-zebra.xsl to correctly process a new syntax >for defining facet indexes on the XML files. > >It also changes the retrieval file to allow access to Zebra's internal data from >Zoom (i.e. access to zebra::facet:*). > >Sponsored-by: Universidad Nacional de Cordoba >Signed-off-by: David Cook <dcook@prosentient.com.au> > >Seems to work with DOM and MARC21. > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > debian/templates/marc21-retrieval-info-bib-dom.xml | 2 + > .../templates/normarc-retrieval-info-bib-dom.xml | 2 + > .../templates/unimarc-retrieval-info-bib-dom.xml | 2 + > etc/zebradb/retrieval-info-bib-dom.xml | 7 ++ > etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl | 100 +++++++++++++++++++-- > 5 files changed, 108 insertions(+), 5 deletions(-) > >diff --git a/debian/templates/marc21-retrieval-info-bib-dom.xml b/debian/templates/marc21-retrieval-info-bib-dom.xml >index 7e45f38..c7ce0ac 100644 >--- a/debian/templates/marc21-retrieval-info-bib-dom.xml >+++ b/debian/templates/marc21-retrieval-info-bib-dom.xml >@@ -14,9 +14,11 @@ > outputcharset="utf-8"/> > </backend> > </retrieval> >+ <retrieval syntax="xml"/> > <retrieval syntax="xml" name="index"/> <!-- allow viewing index entries --> > <retrieval syntax="xml" name="marc" > identifier="info:srw/schema/1/marcxml-v1.1"/> > <retrieval syntax="xml" name="marcxml" > identifier="info:srw/schema/1/marcxml-v1.1"/> >+ <retrieval syntax="xml" name="zebra::*" /> > </retrievalinfo> >diff --git a/debian/templates/normarc-retrieval-info-bib-dom.xml b/debian/templates/normarc-retrieval-info-bib-dom.xml >index f723f9a..9d62631 100644 >--- a/debian/templates/normarc-retrieval-info-bib-dom.xml >+++ b/debian/templates/normarc-retrieval-info-bib-dom.xml >@@ -14,9 +14,11 @@ > outputcharset="utf-8"/> > </backend> > </retrieval> >+ <retrieval syntax="xml"/> > <retrieval syntax="xml" name="index"/> <!-- allow viewing index entries --> > <retrieval syntax="xml" name="marc" > identifier="info:srw/schema/1/marcxml-v1.1"/> > <retrieval syntax="xml" name="marcxml" > identifier="info:srw/schema/1/marcxml-v1.1"/> >+ <retrieval syntax="xml" name="zebra::*" /> > </retrievalinfo> >diff --git a/debian/templates/unimarc-retrieval-info-bib-dom.xml b/debian/templates/unimarc-retrieval-info-bib-dom.xml >index 941f8e8..7699dc5 100644 >--- a/debian/templates/unimarc-retrieval-info-bib-dom.xml >+++ b/debian/templates/unimarc-retrieval-info-bib-dom.xml >@@ -14,9 +14,11 @@ > outputcharset="utf-8"/> > </backend> > </retrieval> >+ <retrieval syntax="xml"/> > <retrieval syntax="xml" name="index"/> <!-- allow viewing index entries --> > <retrieval syntax="xml" name="marc" > identifier="info:srw/schema/1/marcxml-v1.1"/> > <retrieval syntax="xml" name="marcxml" > identifier="info:srw/schema/1/marcxml-v1.1"/> >+ <retrieval syntax="xml" name="zebra::*" /> > </retrievalinfo> >diff --git a/etc/zebradb/retrieval-info-bib-dom.xml b/etc/zebradb/retrieval-info-bib-dom.xml >index c966937..4fe781d 100644 >--- a/etc/zebradb/retrieval-info-bib-dom.xml >+++ b/etc/zebradb/retrieval-info-bib-dom.xml >@@ -15,4 +15,11 @@ > </backend> > </retrieval> > <retrieval syntax="xml"/> >+ <retrieval syntax="xml" name="index"/> <!-- allow viewing index entries --> >+ <retrieval syntax="xml" name="marc" >+ identifier="info:srw/schema/1/marcxml-v1.1"/> >+ <retrieval syntax="xml" name="marcxml" >+ identifier="info:srw/schema/1/marcxml-v1.1"/> >+<!-- enable access to Zebra's internal data --> >+ <retrieval syntax="xml" name="zebra::*" /> > </retrievalinfo> >diff --git a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >index 1488b1c..03e635f 100644 >--- a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >+++ b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >@@ -12,10 +12,11 @@ > <xsl:template match="text()"/> > > <!-- Keys on tags referenced in the index definitions --> >- <xsl:key name="index_control_field_tag" match="kohaidx:index_control_field" use="@tag"/> >- <xsl:key name="index_subfields_tag" match="kohaidx:index_subfields" use="@tag"/> >- <xsl:key name="index_heading_tag" match="kohaidx:index_heading" use="@tag"/> >- <xsl:key name="index_data_field_tag" match="kohaidx:index_data_field" use="@tag"/> >+ <xsl:key name="index_control_field_tag" match="kohaidx:index_control_field" use="@tag"/> >+ <xsl:key name="index_subfields_tag" match="kohaidx:index_subfields" use="@tag"/> >+ <xsl:key name="index_facet_tag" match="kohaidx:facet" use="@tag"/> >+ <xsl:key name="index_heading_tag" match="kohaidx:index_heading" use="@tag"/> >+ <xsl:key name="index_data_field_tag" match="kohaidx:index_data_field" use="@tag"/> > <xsl:key name="index_heading_conditional_tag" match="kohaidx:index_heading_conditional" use="@tag"/> > <xsl:key name="index_match_heading_tag" match="kohaidx:index_match_heading" use="@tag"/> > >@@ -33,6 +34,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"/> >@@ -57,6 +59,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"/> >@@ -69,6 +72,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xsl:call-template name="handle-index-control-field"/> > <xsl:call-template name="handle-index-subfields"/> > <xsl:call-template name="handle-index-data-field"/> >+ <xsl:call-template name="handle-index-facets"/> > <xsl:call-template name="handle-index-heading"/> > <xsl:call-template name="handle-index-heading-conditional"/> > <xsl:call-template name="handle-index-match-heading"/> >@@ -104,7 +108,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > </xslo:variable> > </xsl:template> > >- <xsl:template match="kohaidx:index_subject_thesaurus"> >+ <xsl:template match="kohaidx:index_subject_thesaurus"> > <xsl:variable name="tag"><xsl:value-of select="@tag"/></xsl:variable> > <xsl:variable name="offset"><xsl:value-of select="@offset"/></xsl:variable> > <xsl:variable name="length"><xsl:value-of select="@length"/></xsl:variable> >@@ -288,6 +292,38 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > </xslo:for-each> > </xsl:template> > >+ <xsl:template name="handle-index-facets"> >+ <xsl:for-each select="//kohaidx:facet[generate-id() = generate-id(key('index_facet_tag', @tag)[1])]"> >+ <xslo:template mode="index_facets"> >+ <xsl:attribute name="match"> >+ <xsl:text>marc:datafield[@tag='</xsl:text> >+ <xsl:value-of select="@tag"/> >+ <xsl:text>']</xsl:text> >+ </xsl:attribute> >+ <xslo:if> >+ <xsl:attribute name="test"> >+ <xsl:text>not(@ind1='z')</xsl:text> >+ </xsl:attribute> >+ <xsl:for-each select="key('index_facet_tag', @tag)"> >+ <xsl:variable name="indexes"> >+ <xsl:call-template name="get-facets-target-indexes"/> >+ </xsl:variable> >+ <xsl:if test="not($indexes='')"> >+ <z:index> >+ <xsl:attribute name="name"> >+ <xsl:value-of select="normalize-space($indexes)"/> >+ </xsl:attribute> >+ <xsl:call-template name="build-facet-value"> >+ <xsl:with-param name="subfields" select="@subfields"/> >+ </xsl:call-template> >+ </z:index> >+ </xsl:if> >+ </xsl:for-each> >+ </xslo:if> >+ </xslo:template> >+ </xsl:for-each> >+ </xsl:template> >+ > <xsl:template name="handle-index-data-field"> > <xsl:for-each select="//kohaidx:index_data_field[generate-id() = generate-id(key('index_data_field_tag', @tag)[1])]"> > <xslo:template mode="index_data_field"> >@@ -475,4 +511,58 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xsl:value-of select="." /><xsl:text> </xsl:text> > </xsl:for-each> > </xsl:template> >+ >+ <xsl:template name="get-facets-target-indexes"> >+ <xsl:for-each select="kohaidx:target_index"> >+ <xsl:value-of select="." /><xsl:text> </xsl:text> >+ </xsl:for-each> >+ </xsl:template> >+ >+ <!-- traverse subfields string character-wise --> >+ <xsl:template name="build-facet-value"> >+ <xsl:param name="subfields"/> >+ <xsl:if test="string-length($subfields) > 0"> >+ <xslo:value-of> >+ <xsl:attribute name="select"> >+ <xsl:text>marc:subfield[@code='</xsl:text> >+ <xsl:value-of select="substring($subfields,1,1)"/> >+ <xsl:text>']</xsl:text> >+ </xsl:attribute> >+ </xslo:value-of> >+ <xsl:call-template name="build-facet-value-cont"> >+ <xsl:with-param name="prev" select="substring($subfields,1,1)"/> >+ <xsl:with-param name="subfields" select="substring($subfields,2)"/> >+ </xsl:call-template> >+ </xsl:if> >+ </xsl:template> >+ <!-- traverse the remainder of @subfields, with context information >+ i.e previous char. Introduces a separator character if needed --> >+ <xsl:template name="build-facet-value-cont"> >+ <xsl:param name="prev"/> >+ <xsl:param name="subfields"/> >+ <xsl:if test="string-length($subfields) > 0"> >+ <xslo:if> >+ <xsl:attribute name="test"> >+ <xsl:text>marc:subfield[@code='</xsl:text> >+ <xsl:value-of select="$prev"/> >+ <xsl:text>'] and marc:subfield[@code='</xsl:text> >+ <xsl:value-of select="substring($subfields,1,1)"/> >+ <xsl:text>']</xsl:text> >+ </xsl:attribute> >+ <xslo:text><*></xslo:text> >+ </xslo:if> >+ <xslo:value-of> >+ <xsl:attribute name="select"> >+ <xsl:text>marc:subfield[@code='</xsl:text> >+ <xsl:value-of select="substring($subfields,1,1)"/> >+ <xsl:text>']</xsl:text> >+ </xsl:attribute> >+ </xslo:value-of> >+ <xsl:call-template name="build-facet-value-cont"> >+ <xsl:with-param name="prev" select="substring($subfields,1,1)"/> >+ <xsl:with-param name="subfields" select="substring($subfields,2)"/> >+ </xsl:call-template> >+ </xsl:if> >+ </xsl:template> >+ > </xsl:stylesheet> >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11232
:
26911
|
31426
|
31427
|
31428
|
31429
|
31430
|
31431
|
31432
|
31433
|
31434
|
31435
|
31436
|
31455
|
31456
|
31457
|
31458
|
31459
|
31460
|
31781
|
31782
|
31783
|
31784
|
31785
|
31786
|
31795
|
31796
|
31797
|
31798
|
31799
|
31800
|
32152
|
32153
|
32154
|
32155
|
32156
|
32157
|
32330
|
32331
|
32350
| 32352 |
32353
|
32354
|
32355
|
32356
|
32357
|
32358
|
32359
|
32360