Changeset 13822


Ignore:
Timestamp:
2007-01-26T14:04:49+13:00 (17 years ago)
Author:
mdewsnip
Message:

A quick attempt to fix MetadataXMLPlug so it will parse metadata.xml files containing UTF-8 element names (ie. attribute values in the XML). Unfortunately, this seems to work differently depending on the version of Perl. Not tested on Windows!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/MetadataXMLPlug.pm

    r13189 r13822  
    132132   
    133133    # create XML::Parser object for parsing metadata.xml files
    134     my $parser = new XML::Parser('Style' => 'Stream',
    135                  'Handlers' => {'Char' => \&Char,
    136                         'Doctype' => \&Doctype
    137                         });
    138    
     134    my $parser;
     135    if ($]<5.008) {
     136    # Perl 5.6
     137    $parser = new XML::Parser('Style' => 'Stream',
     138                  'Handlers' => {'Char' => \&Char,
     139                         'Doctype' => \&Doctype
     140                         });
     141    }
     142    else {
     143    # Perl 5.8
     144    $parser = new XML::Parser('Style' => 'Stream',
     145                  'ProtocolEncoding' => 'ISO-8859-1',
     146                  'Handlers' => {'Char' => \&Char,
     147                         'Doctype' => \&Doctype
     148                         });
     149    }
     150
    139151    $self->{'parser'} = $parser;
    140152    $self->{'in_filename'} = 0;
     
    262274# things down significantly in some cases.
    263275sub Char {
    264     use bytes;  # Necessary to prevent encoding issues with XML::Parser 2.31+
     276    if ($]<5.008) {
     277    use bytes;  # Necessary to prevent encoding issues with XML::Parser 2.31+ and Perl 5.6
     278    }
    265279    $_[0]->{'Text'} .= $_[1];
    266280    return undef;
Note: See TracChangeset for help on using the changeset viewer.