Changeset 17054

Show
Ignore:
Timestamp:
28.08.2008 13:18:10 (11 years ago)
Author:
kjdon
Message:

a previous change to ReadXMLFile meant that all namespaces were stripped out of the parsed XML. Have modified all the element name tests to use regular expressions with the namespace optional

Files:
1 modified

Legend:

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

    r17028 r17054  
    132132    my $self = shift(@_); 
    133133    my ($expat, $element) = @_; 
    134  
    135134    $self->{'element'} = $element; 
    136  
    137135    #**deal with dmdSection 
    138     if ($element eq "mets:dmdSec" || $element eq "gsdl3:Metadata"){     
     136    if ($element =~ /^(mets:)?dmdSec$/ || $element =~ /(gsdl3:)?Metadata$/){  
    139137    $self->xml_dmd_start_tag (@_); 
    140     } elsif ($element eq "mets:file") { 
     138    } elsif ($element =~ /^(mets:)?file$/) { 
    141139    $_{'ID'} =~ m/FILE(.*)/; 
    142140    $self->{'file_Id'} = $1; 
    143     } elsif ($element eq "mets:FLocat"){ 
     141    } elsif ($element =~ /^(mets:)?FLocat$/){ 
    144142    #***deal with fileSection 
    145143    $self->xml_fileloc_start_tag (@_); 
    146     } elsif ($element eq "mets:div"){ 
     144    } elsif ($element =~ /^(mets:)?div$/){ 
    147145    #***deal with StrucMap Section 
    148146    $self->xml_strucMap_start_tag (@_); 
     
    154152    my ($expat, $element) = @_; 
    155153 
    156     if ($element eq "mets:dmdSec"){ 
     154    if ($element =~ /^(mets:)?dmdSec$/){ 
    157155    my ($section_num) = ($_{'ID'} =~ m/DM(.*)/); 
    158156    $self->{'dmdSec_table'}->{"$section_num"}=[]; 
    159157    $self->{'dmdSec_table'}->{'section_num'}=$section_num; 
    160     } elsif ($element eq "gsdl3:Metadata") { 
     158    } elsif ($element =~ /^(gsdl3:)?Metadata$/) { 
    161159    $self->{'metadata_name'} = $_{'name'}; 
    162160    } 
     
    168166 
    169167    my $xlink = $_{'xlink:href'}; 
     168    if (!defined $xlink) { 
     169    # try without namespace 
     170    $xlink = $_{'href'}; 
     171    } 
    170172    #my ($section_num) = ($_{'ID'} =~ m/^FLOCAT(.*)$/); 
    171173    my $section_num = $self->{'file_Id'}; 
    172  
    173174    return if (!defined $section_num);  
    174175    #**return if the section_num is not defined or not deal with the whole section (ID="default.*") 
     
    178179     
    179180    my ($filename,$xpath_expr)=($xlink =~ m/^file:(.*)\#xpointer\((.*)\)$/); 
    180      
    181181    my $nodeset = $self->{'parsed_xml'}->findnodes ($xpath_expr); 
    182182    my $node_size= $nodeset->size; 
     
    189189        my $xml_content = XML::XPath::XMLParser::as_string($node); 
    190190        my $unescaped_xml_content = &ghtml::unescape_html($xml_content); 
    191  
    192191        my $section_content={'section_content'=> $unescaped_xml_content}; 
    193192         
     
    244243    my ($expat, $element) = @_; 
    245244 
    246     if ($element eq "gsdl3:Metadata") { 
     245    if ($element =~ /^(gsdl3:)?Metadata$/) { 
    247246    my $section_num = $self->{'dmdSec_table'}->{'section_num'}; 
    248247    my $metadata_name=$self->{'metadata_name'}; 
     
    258257    $self->{'metadata_name'} = ""; 
    259258    $self->{'metadata_value'} = ""; 
    260     } elsif ($element eq "mets:file"){ 
     259    } elsif ($element =~ /^(mets:)?file$/){ 
    261260    $self->{'file_id'} = ""; 
    262261    } 
     
    264263     
    265264    #*** StrucMap Section 
    266     if ($element eq "mets:div") { 
     265    if ($element =~ /^(mets:)?div$/) { 
    267266    $self->{'section_level'}--; 
    268267    $self->{'section'} = $self->{'doc_obj'}->get_parent_section($self->{'section'}); 
     
    276275    my ($expat) = @_;  
    277276 
    278     if ($self->{'element'} eq "gsdl3:Metadata") { 
     277    if ($self->{'element'} =~ /^(gsdl3:)?Metadata$/) { 
    279278    $self->{'metadata_value'} .= $_; 
    280279    }