r11304 - in /branches/upstream/libmarc-xml-perl/current: Changes MANIFEST META.yml Makefile.PL lib/MARC/File/SAX.pm lib/MARC/File/XML.pm t/subfield0.t t/subfield0.xml
gregoa-guest at users.alioth.debian.org
gregoa-guest at users.alioth.debian.org
Mon Dec 17 17:23:40 UTC 2007
Author: gregoa-guest
Date: Mon Dec 17 17:23:40 2007
New Revision: 11304
URL: http://svn.debian.org/wsvn/?sc=1&rev=11304
Log:
[svn-upgrade] Integrating new upstream version, libmarc-xml-perl (0.88)
Added:
branches/upstream/libmarc-xml-perl/current/t/subfield0.t
branches/upstream/libmarc-xml-perl/current/t/subfield0.xml
Modified:
branches/upstream/libmarc-xml-perl/current/Changes
branches/upstream/libmarc-xml-perl/current/MANIFEST
branches/upstream/libmarc-xml-perl/current/META.yml
branches/upstream/libmarc-xml-perl/current/Makefile.PL
branches/upstream/libmarc-xml-perl/current/lib/MARC/File/SAX.pm
branches/upstream/libmarc-xml-perl/current/lib/MARC/File/XML.pm
Modified: branches/upstream/libmarc-xml-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/Changes?rev=11304&op=diff
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/Changes (original)
+++ branches/upstream/libmarc-xml-perl/current/Changes Mon Dec 17 17:23:40 2007
@@ -1,4 +1,13 @@
Revision history for Perl extension MARC-XML
+
+0.88 Wed Nov 28 2007
+ - String test for subfield code to avoid dropping $0 (Galen Charlton)
+
+0.88_1 Tue Oct 23 2007
+ - Fixed a typo in M::F::X that could be the origin of the test failure(miker)
+ - Removed some useless (and confusing) code that
+ throws away some character set mapping information in the 066 (miker)
+
0.85 Fri Feb 13 2007
- fixed typo in handling of unimarc w/regard to marc8 (ppoulain)
Modified: branches/upstream/libmarc-xml-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/MANIFEST?rev=11304&op=diff
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/MANIFEST (original)
+++ branches/upstream/libmarc-xml-perl/current/MANIFEST Mon Dec 17 17:23:40 2007
@@ -7,6 +7,8 @@
bin/xml2marc
lib/MARC/File/XML.pm
lib/MARC/File/SAX.pm
+t/subfield0.t
+t/subfield0.xml
t/batch.t
t/batch.xml
t/encode.t
Modified: branches/upstream/libmarc-xml-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/META.yml?rev=11304&op=diff
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/META.yml (original)
+++ branches/upstream/libmarc-xml-perl/current/META.yml Mon Dec 17 17:23:40 2007
@@ -1,13 +1,16 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: MARC-XML
-version: 0.87
-version_from: lib/MARC/File/XML.pm
-installdirs: site
-requires:
- MARC::Charset: 0.91
- MARC::Record: 1.36
+--- #YAML:1.0
+name: MARC-XML
+version: 0.88
+abstract: ~
+license: ~
+generated_by: ExtUtils::MakeMaker version 6.36
+distribution_type: module
+requires:
+ MARC::Charset: 0.98
+ MARC::Record: 2
XML::SAX: 0.12
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.2.html
+ version: 1.2
+author:
+ - Ed Summers <ehs at pobox.com>
Modified: branches/upstream/libmarc-xml-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/Makefile.PL?rev=11304&op=diff
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/Makefile.PL (original)
+++ branches/upstream/libmarc-xml-perl/current/Makefile.PL Mon Dec 17 17:23:40 2007
@@ -8,8 +8,8 @@
'AUTHOR' => 'Ed Summers <ehs at pobox.com>',
'PREREQ_PM' => {
'XML::SAX' => 0.12,
- 'MARC::Record' => 1.36,
- 'MARC::Charset' => 0.91,
+ 'MARC::Record' => 2.0,
+ 'MARC::Charset' => 0.98,
},
'EXE_FILES' => [ qw( bin/marc2xml bin/xml2marc ) ]
);
Modified: branches/upstream/libmarc-xml-perl/current/lib/MARC/File/SAX.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/lib/MARC/File/SAX.pm?rev=11304&op=diff
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/lib/MARC/File/SAX.pm (original)
+++ branches/upstream/libmarc-xml-perl/current/lib/MARC/File/SAX.pm Mon Dec 17 17:23:40 2007
@@ -80,7 +80,7 @@
sub characters {
my ( $self, $chars ) = @_;
- if ( $self->{ subcode } or ( $self->{ tag } and
+ if ( ( exists $self->{ subcode } and $self->{ subcode } ne '') or ( $self->{ tag } and
( $self->{ tag } eq 'LDR' or $self->{ tag } < 10 ) ) ) {
$self->{ chars } .= $chars->{ Data };
}
Modified: branches/upstream/libmarc-xml-perl/current/lib/MARC/File/XML.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/lib/MARC/File/XML.pm?rev=11304&op=diff
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/lib/MARC/File/XML.pm (original)
+++ branches/upstream/libmarc-xml-perl/current/lib/MARC/File/XML.pm Mon Dec 17 17:23:40 2007
@@ -14,7 +14,7 @@
use Carp qw( croak );
use Encode ();
-$VERSION = '0.87';
+$VERSION = '0.88';
my $handler = MARC::File::SAX->new();
@@ -179,19 +179,30 @@
=head2 out()
A constructor for creating a MARC::File::XML object that can write XML to a
-file. You must pass in the name of a file to write XML to.
-
- my $file = MARC::File::XML->out( $filename );
+file. You must pass in the name of a file to write XML to. If the $encoding
+parameter or the DefaultEncoding (see above) is set to UTF-8 then the binmode
+of the output file will be set appropriately.
+
+ my $file = MARC::File::XML->out( $filename [, $encoding] );
=cut
sub out {
- my ( $class, $filename ) = @_;
+ my ( $class, $filename, $enc ) = @_;
my $fh = IO::File->new( ">$filename" ) or croak( $! );
+ $enc ||= $_load_args{DefaultEncoding};
+
+ if ($enc =~ /^utf-?8$/oi) {
+ $fh->binmode(':utf8');
+ } else {
+ $fh->binmode(':raw');
+ }
+
my %self = (
filename => $filename,
fh => $fh,
- header => 0
+ header => 0,
+ encoding => $enc
);
return( bless \%self, ref( $class ) || $class );
}
@@ -216,7 +227,7 @@
}
## print the XML header if we haven't already
if ( ! $self->{ header } ) {
- $enc ||= $_load_args{DefaultEncoding};
+ $enc ||= $self->{ encoding } || $_load_args{DefaultEncoding};
$self->{ fh }->print( header( $enc ) );
$self->{ header } = 1;
}
@@ -309,22 +320,12 @@
my $_transcode = 0;
my $ldr = $record->leader;
- my $original_charset;
my $original_encoding = substr($ldr,9,1);
# Does the record think it is already Unicode?
- if ($original_encoding ne 'a' && lc($format) ne 'unimarc') {
- # If not, we'll make it so
+ if ($original_encoding ne 'a' && lc($format) !~ /^unimarc/o) {
+ # If not, we'll make it so
$_transcode++;
-
- # XXX Need to generat a '066' field here, but I don't understand how yet.
-
- substr($ldr,9,1,'a');
- $record->leader( $ldr );
- if ( ($original_charset) = $record->field('066') ) {
- $record->delete_field( $original_charset );
- }
-
}
my @xml = ();
@@ -333,23 +334,23 @@
push @xml, <<HEADER
<?xml version="1.0" encoding="$enc"?>
<record
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/ standards/marcxml/schema/MARC21slim.xsd"
- xmlns="http://www.loc.gov/MARC21/slim">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/ standards/marcxml/schema/MARC21slim.xsd"
+ xmlns="http://www.loc.gov/MARC21/slim">
HEADER
} else {
push( @xml, "<record>" );
}
-
+
push( @xml, " <leader>" . escape( $record->leader ) . "</leader>" );
foreach my $field ( $record->fields() ) {
my $tag = $field->tag();
if ( $field->is_control_field() ) {
- my $data = $field->data;
+ my $data = $field->data;
push( @xml, qq( <controlfield tag="$tag">) .
- escape( ($_transcode ? marc8_to_utf8($data) : $data) ). qq(</controlfield>) );
+ escape( ($_transcode ? marc8_to_utf8($data) : $data) ). qq(</controlfield>) );
} else {
my $i1 = $field->indicator( 1 );
my $i2 = $field->indicator( 2 );
@@ -357,7 +358,7 @@
foreach my $subfield ( $field->subfields() ) {
my ( $code, $data ) = @$subfield;
push( @xml, qq( <subfield code="$code">).
- escape( ($_transcode ? marc8_to_utf8($data) : $data) ).qq(</subfield>) );
+ escape( ($_transcode ? marc8_to_utf8($data) : $data) ).qq(</subfield>) );
}
push( @xml, " </datafield>" );
}
@@ -365,11 +366,8 @@
push( @xml, "</record>\n" );
if ($_transcode) {
- if (defined $original_charset) {
- $record->insert_fields_ordered($original_charset);
- }
- substr($ldr,9,1,$original_encoding);
- $record->leader( $ldr );
+ substr($ldr,9,1,$original_encoding);
+ $record->leader( $ldr );
}
return( join( "\n", @xml ) );
Added: branches/upstream/libmarc-xml-perl/current/t/subfield0.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/t/subfield0.t?rev=11304&op=file
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/t/subfield0.t (added)
+++ branches/upstream/libmarc-xml-perl/current/t/subfield0.t Mon Dec 17 17:23:40 2007
@@ -1,0 +1,11 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+use MARC::Batch;
+
+# verify that SAX parser picks up contents of a subfield $0
+
+my $b = MARC::Batch->new( 'XML', 't/subfield0.xml' );
+my $r = $b->next();
+is($r->subfield('245', '0'), 'subfield $0 contents', 'subfield $0');
+
Added: branches/upstream/libmarc-xml-perl/current/t/subfield0.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-xml-perl/current/t/subfield0.xml?rev=11304&op=file
==============================================================================
--- branches/upstream/libmarc-xml-perl/current/t/subfield0.xml (added)
+++ branches/upstream/libmarc-xml-perl/current/t/subfield0.xml Mon Dec 17 17:23:40 2007
@@ -1,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<collection xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <record xmlns="">
+ <leader>-----nas-a22-----z--4500</leader>
+ <datafield tag="245" ind1="0" ind2="0">
+ <subfield code="a">19th century music</subfield>
+ <subfield code="h">[electronic resource]</subfield>
+ <subfield code="0">subfield $0 contents</subfield>
+ </datafield>
+ </record>
+</collection>
More information about the Pkg-perl-cvs-commits
mailing list