Bugzilla – Attachment 30783 Details for
Bug 12754
Add XSLT action to MARC modification templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12754: Perform the actual XSLT action for marc mod template
Bug-12754-Perform-the-actual-XSLT-action-for-marc-.patch (text/plain), 2.76 KB, created by
Marcel de Rooy
on 2014-08-14 10:55:08 UTC
(
hide
)
Description:
Bug 12754: Perform the actual XSLT action for marc mod template
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-08-14 10:55:08 UTC
Size:
2.76 KB
patch
obsolete
>From 99366cb99b8ec4cffdb5766565420be129d86b48 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 13 Aug 2014 16:10:27 +0200 >Subject: [PATCH] Bug 12754: Perform the actual XSLT action for marc mod > template >Content-Type: text/plain; charset=utf-8 > >This patch modifies MarcModificationTemplates.pm. >A local subroutine _RunXSLTAction is added to perform the actual xslt >transformation using the XSLTHandler object. > >Test plan: >Add some XSLT actions to a marc mod template. >Run Stage for Import and select the correct marc mod template. >Check your staged records for the expected changes (you can also view these >reservoir records in Cataloging search). >--- > C4/MarcModificationTemplates.pm | 23 +++++++++++++++++++++++ > 1 files changed, 23 insertions(+), 0 deletions(-) > >diff --git a/C4/MarcModificationTemplates.pm b/C4/MarcModificationTemplates.pm >index a470066..d3d60e4 100644 >--- a/C4/MarcModificationTemplates.pm >+++ b/C4/MarcModificationTemplates.pm >@@ -23,11 +23,14 @@ use DateTime; > > use C4::Context; > use Koha::SimpleMARC; >+use Koha::XSLT_Handler; > > use vars qw($VERSION @ISA @EXPORT); > > use constant DEBUG => 0; > >+my $engine; #XSLT Handler object >+ > BEGIN { > $VERSION = 1.00; # set the version for version checking > @ISA = qw(Exporter); >@@ -47,6 +50,7 @@ BEGIN { > &ModifyRecordsWithTemplate > &ModifyRecordWithTemplate > ); >+ $engine=Koha::XSLT_Handler->new(); > } > > >@@ -508,6 +512,7 @@ sub ModifyRecordWithTemplate { > > foreach my $a ( @actions ) { > my $action = $a->{'action'}; >+ > my $field_number = $a->{'field_number'}; > my $from_field = $a->{'from_field'}; > my $from_subfield = $a->{'from_subfield'}; >@@ -536,6 +541,8 @@ sub ModifyRecordWithTemplate { > ? ( undef, $field_value ) > : () > ); >+ } elsif ( $action eq 'run_xslt' ) { >+ #nothing to do > } else { > push @params, > ( $field_value >@@ -607,11 +614,27 @@ sub ModifyRecordWithTemplate { > elsif ( $action eq 'delete_field' ) { > delete_field(@params); > } >+ elsif ( $action eq 'run_xslt' ) { >+ _RunXSLTAction ( $record, $a->{run_xslt} ); >+ } > } > > warn( $record->as_formatted() ) if DEBUG >= 10; > } > } >+ >+sub _RunXSLTAction { >+ my ( $record, $xsl )= @_; >+ my $xml= $engine->transform($record->as_xml, $xsl ); >+ if ( $engine->err ) { >+ warn "XSLT marc mod template action failed with $xsl"; >+ } else { >+ my $newrecord= MARC::Record->new_from_xml($xml, 'UTF-8'); >+ $record->delete_fields( $record->fields() ); #clear all fields >+ $record->append_fields( $newrecord->fields() ); >+ } >+} >+ > 1; > __END__ > >-- >1.7.7.6
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 12754
:
30754
|
30756
|
30757
|
30758
|
30759
|
30782
| 30783 |
30784