[Koha-bugs] [Bug 14217] Add a DOM syntax for specifying conditions on indexes
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Wed Jul 8 19:20:24 CEST 2015
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14217
--- Comment #2 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 40842
-->
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=40842&action=edit
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/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
Sponsored-by: Orex Digital
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list