Changeset 21905

Show
Ignore:
Timestamp:
19.04.2010 14:05:50 (10 years ago)
Author:
mdewsnip
Message:

Changes made by Jeffrey Ke at DL Consulting Ltd to remove the global $self variable, so more than one variant of MetadataXMLPlugin (e.g. if you subclass MetadataXMLPlugin.pm) can be included in a collection without everything going pear-shaped.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm

    r20803 r21905  
    115115        'args'     => $arguments }; 
    116116 
    117 my ($self); 
    118  
    119117sub new { 
    120118    my ($class) = shift (@_); 
     
    125123    push(@{$hashArgOptLists->{"OptList"}},$options); 
    126124 
    127     $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists); 
     125    my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists); 
    128126 
    129127    if ($self->{'info_only'}) { 
     
    137135    # Perl 5.6 
    138136    $parser = new XML::Parser('Style' => 'Stream', 
     137                                  'PluginObj' => $self, 
    139138                  'Handlers' => {'Char' => \&Char, 
    140139                         'Doctype' => \&Doctype 
     
    144143    # Perl 5.8 
    145144    $parser = new XML::Parser('Style' => 'Stream', 
     145                                  'PluginObj' => $self, 
    146146                  'ProtocolEncoding' => 'ISO-8859-1', 
    147147                  'Handlers' => {'Char' => \&Char, 
     
    220220} 
    221221 
    222 sub Doctype { 
     222 
     223# Updated by Jeffrey 2010/04/16 @ DL Consulting Ltd. 
     224# Get rid off the global $self as it cause problems when there are 2+ MetadataXMLPlugin in your collect.cfg... 
     225# For example when you have an OAIMetadataXMLPlugin that is a child of MetadataXMLPlugin 
     226sub Doctype {$_[0]->{'PluginObj'}->xml_doctype(@_);} 
     227sub StartTag {$_[0]->{'PluginObj'}->xml_start_tag(@_);} 
     228sub EndTag {$_[0]->{'PluginObj'}->xml_end_tag(@_);} 
     229sub Text {$_[0]->{'PluginObj'}->xml_text(@_);} 
     230 
     231 
     232sub xml_doctype { 
     233    my $self = shift(@_); 
    223234    my ($expat, $name, $sysid, $pubid, $internal) = @_; 
    224235 
     
    229240} 
    230241 
    231 sub StartTag { 
     242sub xml_start_tag { 
     243    my $self = shift(@_); 
    232244    my ($expat, $element) = @_; 
    233245 
     
    250262} 
    251263 
    252 sub EndTag { 
     264sub xml_end_tag { 
     265    my $self = shift(@_); 
    253266    my ($expat, $element) = @_; 
    254267 
     
    291304} 
    292305 
    293 sub Text { 
     306sub xml_text { 
     307    my $self = shift(@_); 
    294308 
    295309    if ($self->{'in_filename'}) {