Ignore:
Timestamp:
2007-05-28T13:35:30+12:00 (17 years ago)
Author:
sjboddie
Message:

Fixed up the way XMLPlug is implemented, so it no longer relies on $self
being a global variable. This change should not make any functional
difference, but will allow inheritance to work properly.

File:
1 edited

Legend:

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

    r13226 r14103  
    5656        'args'     => $arguments };
    5757
    58 
    59 our ($self);
    6058sub new {
    6159    my ($class) = shift (@_);
     
    6765   
    6866    # $self is global for use within subroutines called by XML::Parser
    69     $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists);
     67    my $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists);
    7068
    7169    if ($self->{'info_only'}) {
     
    7573
    7674    my $parser = new XML::Parser('Style' => 'Stream',
     75                                 'Pkg' => 'XMLPlug',
     76                                 'PluginObj' => $self,
    7777                 'Handlers' => {'Char' => \&Char,
    7878                        'XMLDecl' => \&XMLDecl,
     
    8080                        'Doctype' => \&Doctype,
    8181                        'Default' => \&Default,
    82                         }); 
     82                                 });
    8383
    8484    $self->{'parser'} = $parser;
     
    160160
    161161sub check_doctype {
    162     $self = shift (@_);
     162    my $self = shift (@_);
    163163   
    164164    my ($filename) = @_;
    165    
     165
    166166    if (open(XMLIN,"<$filename")) {
    167167    my $doctype = $self->get_doctype();
     
    190190# because we are not just using process_exp to determine whether to process or not, we need to implement this too, so that a file can be passed down if we are not actually processing it
    191191sub metadata_read {
    192     $self = shift (@_);
     192    my $self = shift (@_);
    193193   
    194194    my ($pluginfo, $base_dir, $file, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli) = @_;
     
    208208
    209209sub read {
    210     # $self must be global to work with XML callback routines.
    211     $self = shift (@_); 
     210    my $self = shift (@_); 
    212211 
    213212    my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
     
    275274# plugin that inherits from this. it seems that you can't call the parse
    276275# methods directly. WHY???
     276#
     277# [Stefan 27/5/07] These two methods may not be necessary any more as I've
     278# fixed XMLPlug so $self is no longer required to be a global variable
     279# (that was why inheritance wasn't working quite right with XMLPlug I
     280# think). I don't really know what other plugins rely on these methods
     281# though so have left them here for now.
    277282sub parse_file {
    278     $self = shift (@_);
     283    my $self = shift (@_);
    279284    my ($filename) = @_;
    280285    $self->{'parser'}->parsefile($filename);
     
    282287
    283288sub parse_string {
    284     $self = shift (@_);
     289    my $self = shift (@_);
    285290    my ($xml_string) = @_;
    286291    $self->{'parser'}->parse($xml_string);
     
    293298}
    294299
    295 sub StartDocument {$self->xml_start_document(@_);}
    296 sub XMLDecl {$self->xml_xmldecl(@_);}
    297 sub Entity {$self->xml_entity(@_);}
    298 sub Doctype {$self->xml_doctype(@_);}
    299 sub StartTag {$self->xml_start_tag(@_);}
    300 sub EndTag {$self->xml_end_tag(@_);}
    301 sub Text {$self->xml_text(@_);}
    302 sub PI {$self->xml_pi(@_);}
    303 sub EndDocument {$self->xml_end_document(@_);}
    304 sub Default {$self->xml_default(@_);}
     300sub StartDocument {$_[0]->{'PluginObj'}->xml_start_document(@_);}
     301sub XMLDecl {$_[0]->{'PluginObj'}->xml_xmldecl(@_);}
     302sub Entity {$_[0]->{'PluginObj'}->xml_entity(@_);}
     303sub Doctype {$_[0]->{'PluginObj'}->xml_doctype(@_);}
     304sub StartTag {$_[0]->{'PluginObj'}->xml_start_tag(@_);}
     305sub EndTag {$_[0]->{'PluginObj'}->xml_end_tag(@_);}
     306sub Text {$_[0]->{'PluginObj'}->xml_text(@_);}
     307sub PI {$_[0]->{'PluginObj'}->xml_pi(@_);}
     308sub EndDocument {$_[0]->{'PluginObj'}->xml_end_document(@_);}
     309sub Default {$_[0]->{'PluginObj'}->xml_default(@_);}
    305310
    306311# This Char function overrides the one in XML::Parser::Stream to overcome a
Note: See TracChangeset for help on using the changeset viewer.