Re: Can't parse MARC Authority XML files with mx: prefixes in their tags

[email protected] ("Mike Rylander")
Newsgroups perl.perl4lib
Message-ID <[email protected]>
On Tue, Jun 10, 2008 at 1:18 PM, Christopher Morgan <[email protected]> wrote:
> Mike,
>
> Sorry. Since my last post, I did find out how to use the UNIX patch command,
> and applied your patch to SAX.pm. My script still doesn't work, and there
> are no error messages. My earlier script (which worked on the subject
> authority file) now does not work, so I'm wondering if something in the
> patch may be causing this. I have a backup of the SAX.pm file in any case.
>

Well, it turns out I left something out of the patch I sent before.
In the end_element sub, the second line should be

    my $name = $element->{ LocalName };

instead of

    my $name = $element->{ Name };

If you would, you can just edit the installed version of the patched
SAX.pm to test.

The next thing to try would be to remove the namespace test, but leave
the LocalName changes in place.  Anecdotal evidence suggests that some
of the more popular XML parsing engines, or at least the Perl bindings
for them, have problems with namespaces.  I've attached a (complete,
arg!) patch that implements just the LocalName changes and would be
applied to the original version of SAX.pm.

If you don't have time to test all this that's fined, but if not would
you be willing to send a couple of your problem records?

Thanks Christopher,

-- 
Mike Rylander
 | VP, Research and Design
 | Equinox Software, Inc. / The Evergreen Experts
 | phone: 1-877-OPEN-ILS (673-6457)
 | email: [email protected]
 | web: http://www.esilibrary.com
marc_file_sax.2.patch (text/x-diff, 852 B)
Index: MARC/File/SAX.pm
===================================================================
RCS file: /cvsroot/marcpm/marc-xml/lib/MARC/File/SAX.pm,v
retrieving revision 1.6
diff -p -u -r1.6 SAX.pm
--- MARC/File/SAX.pm	27 Nov 2007 20:28:18 -0000	1.6
+++ MARC/File/SAX.pm	12 Jun 2008 13:53:25 -0000
@@ -17,7 +17,7 @@ use MARC::Charset qw(utf8_to_marc8);
 
 sub start_element {
     my ( $self, $element ) = @_;
-    my $name = $element->{ Name };
+    my $name = $element->{ LocalName };
     if ( $name eq 'leader' ) { 
 	$self->{ tag } = 'LDR';
     } elsif ( $name eq 'controlfield' ) {
@@ -33,7 +33,7 @@ sub start_element {
 
 sub end_element { 
     my ( $self, $element ) = @_;
-    my $name = $element->{ Name };
+    my $name = $element->{ LocalName };
     if ( $name eq 'subfield' ) { 
 	push @{ $self->{ subfields } }, $self->{ subcode };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.