Bugzilla – Attachment 14658 Details for
Bug 9415
XML catalog export is missing root node
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0001-Bug-9415-XML-catalog-export-is-missing-root-node.patch (text/plain), 2.92 KB, created by
Fridolin Somers
on 2013-01-17 10:59:08 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2013-01-17 10:59:08 UTC
Size:
2.92 KB
patch
obsolete
>From c084266c4c1a8a80b60ff05ef3b6130afc660f3b Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Thu, 17 Jan 2013 11:42:53 +0100 >Subject: [PATCH] Bug 9415: XML catalog export is missing root node > >When exporting some biblio or authorities records with tools/export.pl (via web client or command-line) : >If choosing XML format, you get a concatenation of full XML records. > >This patch uses MARC::File::XML to create a well formated file. >See http://search.cpan.org/~gmcharlt/MARC-XML-0.93/lib/MARC/File/XML.pm#close%28%29 > >Test plan: >- Go to Tools/Export data >- Enter numbers in from and to biblio number >- Select xml in file format >- Click "Export bibliographic records" >- Save file somewhere >- Look at downloaded file >=> File should look like : > <?xml version="1.0" encoding="UTF-8"?> > <collection > ... > > <record> > ... > </record> > > <record> > ... > </record> > > </collection> >=> "collection" is the root node and XML declaration exists only once >- Do the same for authorities export and command-line use of tools/export.pl >--- > tools/export.pl | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) > >diff --git a/tools/export.pl b/tools/export.pl >index 0415a3a..e8ecd04 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -17,6 +17,7 @@ > # Suite 330, Boston, MA 02111-1307 USA > > use Modern::Perl; >+use MARC::File::XML; > use List::MoreUtils qw(uniq); > use Getopt::Long; > use CGI; >@@ -309,6 +310,7 @@ if ( $op eq "export" ) { > } @{ $sth->fetchall_arrayref }; > } > >+ my $record_header_written = 0; > for my $recordid ( uniq @recordids ) { > if ($deleted_barcodes) { > my $q = " >@@ -374,19 +376,25 @@ if ( $op eq "export" ) { > } > RemoveAllNsb($record) if ($clean); > if ( $output_format eq "xml" ) { >- if ( $marcflavour eq 'UNIMARC' && $record_type eq 'auths' ) >- { >- print $record->as_xml_record('UNIMARCAUTH'); >- } >- else { >- print $record->as_xml_record($marcflavour); >+ unless ($record_header_written) { >+ MARC::File::XML->default_record_format( ( $marcflavour eq 'UNIMARC' && $record_type eq 'auths' ) ? 'UNIMARCAUTH' : $marcflavour ); >+ print MARC::File::XML::header(); >+ print "\n"; >+ $record_header_written = 1; > } >+ print MARC::File::XML::record( $record ); >+ print "\n"; > } > else { > print $record->as_usmarc(); > } > } > } >+ if ($record_header_written) { >+ print MARC::File::XML::footer(); >+ print "\n"; >+ } >+ > exit; > } > elsif ( $format eq "csv" ) { >-- >1.7.9.5 >
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 9415
:
14658
|
14660
|
14661
|
14719
|
16432