Bugzilla – Attachment 42741 Details for
Bug 14217
Add a DOM syntax for specifying conditions on indexes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14217: Add 'condition' attribute for DOM index definition
Bug-14217-Add-condition-attribute-for-DOM-index-de.patch (text/plain), 7.66 KB, created by
Jonathan Druart
on 2015-09-21 16:31:32 UTC
(
hide
)
Description:
Bug 14217: Add 'condition' attribute for DOM index definition
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-21 16:31:32 UTC
Size:
7.66 KB
patch
obsolete
>From 9332452da5335a624b97c6d9cc7050e35dfbf4be Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 8 Jul 2015 12:37:31 -0300 >Subject: [PATCH] Bug 14217: Add 'condition' attribute for DOM index definition > >This patch introduces an extension to the current syntax for DOM index definition. >Specifically, it extends the 'index_subfields' tag to allow adding a 'condition' >attribute that is used as a condition ofr applying the specified index. > >This (exotic) example is self-explanatory: > >The previous syntax (which is keeped by this patch) took this snippet from biblio-koha-indexdefs.xml > > <index_subfields tag="100" subfields="acbd"> > <target_index>Encuadernador:w</target_index> > </index_subfields> > >and generated an XSLT snippet in the DOM indexing XSLT that looks like this: > > <xslo:for-each select="marc:subfield"> > <xslo:if test="contains('acbd', @code)"> > <z:index name="Encuadernador:w"> > <xslo:value-of select="."/> > </z:index> > </xslo:if> > </xslo:for-each> > >This patch introduces this syntax change (note the 'condition' attribute: > > <index_subfields tag="100" subfields="acbd" condition="@ind2='7'"> > <target_index>Encuadernador:w</target_index> > </index_subfields> > >which yields to this XSLT snippet in the DOM indexing XSLT: > > <xslo:if test="@ind2='7'"> > <xslo:for-each select="marc:subfield"> > <xslo:if test="contains('acbd', @code)"> > <z:index name="Encuadernador:w"> > <xslo:value-of select="."/> > </z:index> > </xslo:if> > </xslo:for-each> > </xslo:if> > >To test: >- Verify that the shipped XSLT files are current regarding the shipped index definitions: > $ for i in marc21 normarc unimarc; do > xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl \ > etc/zebradb/marc_defs/$i/biblios/biblio-koha-indexdefs.xml \ > > etc/zebradb/marc_defs/$i/biblios/biblio-zebra-indexdefs.xsl > done > $ git status >(repeat for authorities, skip normarc which doesn't have authorities) >- Apply the patch >- Re-run the previous commands >=> SUCCESS: no changes >- Add a condition to an index_subfields tag (for example, condition="@ind2='7'" in the Author's index >- Regenerate the specific XSLT >=> SUCCESS: doing a diff shows the only change is the code has been wrapped inside an xslo:if using the condition for the test >- Apply the generated xsl to a MARCXML record that has a field matching the condition like this: > $ xsltproc .../biblio-zebra-indexdefs.xsl sample_record.xml >=> SUCCESS: There's an index on the result, containing the configured field/subfields, that matches the criteria. >- Sign off and feel really happy :-D > >Note: the attached sample record includes a 100 field, with ind2=7 and $a=Tomasito > >Edit: This patch was squashed once I figured it got too complex and Jonathan required a followup >to avoid code duplication. > >This avoids code duplication, with the same results. > >Sponsored-by: Orex Digital >Signed-off-by: Barton Chittenden <barton@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl | 71 +++++++++++++++++------------ > 1 file changed, 42 insertions(+), 29 deletions(-) > >diff --git a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >index e970771..9718e26 100644 >--- a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >+++ b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl >@@ -250,7 +250,19 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xsl:text>']</xsl:text> > </xsl:attribute> > <xsl:for-each select="key('index_subfields_tag', @tag)"> >- <xsl:call-template name="handle-one-index-subfields"/> >+ <xsl:choose> >+ <xsl:when test="@condition"> >+ <xslo:if> >+ <xsl:attribute name="test"> >+ <xsl:value-of select="@condition"/> >+ </xsl:attribute> >+ <xsl:call-template name="handle-one-index-subfields" /> >+ </xslo:if> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:call-template name="handle-one-index-subfields" /> >+ </xsl:otherwise> >+ </xsl:choose> > </xsl:for-each> > </xslo:template> > </xsl:for-each> >@@ -262,34 +274,35 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xsl:variable name="indexes"> > <xsl:call-template name="get-target-indexes"/> > </xsl:variable> >- <xslo:for-each select="marc:subfield"> >- <xslo:if> >- <xsl:attribute name="test"> >- <xsl:text>contains('</xsl:text> >- <xsl:value-of select="@subfields"/> >- <xsl:text>', @code)</xsl:text> >- </xsl:attribute> >- <z:index> >- <xsl:attribute name="name"><xsl:value-of select="normalize-space($indexes)"/></xsl:attribute> >- <xslo:value-of> >- <xsl:attribute name="select"> >- <xsl:choose> >- <xsl:when test="@length"> >- <xsl:text>substring(., </xsl:text> >- <xsl:value-of select="$offset + 1" /> >- <xsl:text>, </xsl:text> >- <xsl:value-of select="$length"/> >- <xsl:text>)</xsl:text> >- </xsl:when> >- <xsl:otherwise> >- <xsl:text>.</xsl:text> >- </xsl:otherwise> >- </xsl:choose> >- </xsl:attribute> >- </xslo:value-of> >- </z:index> >- </xslo:if> >- </xslo:for-each> >+ >+ <xslo:for-each select="marc:subfield"> >+ <xslo:if> >+ <xsl:attribute name="test"> >+ <xsl:text>contains('</xsl:text> >+ <xsl:value-of select="@subfields"/> >+ <xsl:text>', @code)</xsl:text> >+ </xsl:attribute> >+ <z:index> >+ <xsl:attribute name="name"><xsl:value-of select="normalize-space($indexes)"/></xsl:attribute> >+ <xslo:value-of> >+ <xsl:attribute name="select"> >+ <xsl:choose> >+ <xsl:when test="@length"> >+ <xsl:text>substring(., </xsl:text> >+ <xsl:value-of select="$offset + 1" /> >+ <xsl:text>, </xsl:text> >+ <xsl:value-of select="$length"/> >+ <xsl:text>)</xsl:text> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:text>.</xsl:text> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:attribute> >+ </xslo:value-of> >+ </z:index> >+ </xslo:if> >+ </xslo:for-each> > </xsl:template> > > <xsl:template name="handle-index-facets"> >-- >2.1.0
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 14217
:
40841
|
40842
|
42045
|
42737
|
42739
|
42740
| 42741