Changeset 6111 for trunk/gsdl/perllib/doc.pm
- Timestamp:
- 2003-12-03T12:02:55+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/doc.pm
r3834 r6111 608 608 609 609 # returns the first metadata value which matches field 610 611 # This version of get metadata element works much like the one above, 612 # except it allows for the namespace portion of a metadata element to 613 # be ignored, thus if you are searching for dc.Title, the first piece 614 # of matching metadata ending with the name Title (once any namespace 615 # is removed) would be returned. 616 # 28-11-2003 John Thompson 610 617 sub get_metadata_element { 611 618 my $self = shift (@_); 612 my ($section, $field ) = @_;619 my ($section, $field, $ignore_namespace) = @_; 613 620 my ($data); 621 622 $ignore_namespace = 0 unless defined $ignore_namespace; 614 623 615 624 my $section_ptr = $self->_lookup_section($section); … … 620 629 } 621 630 631 # Remove the any namespace if we are being told to ignore them 632 if($ignore_namespace) { 633 $field =~ s/^\w*\.//; 634 } 635 622 636 foreach $data (@{$section_ptr->{'metadata'}}) { 623 return $data->[1] if (scalar(@$data) >= 2 && $data->[0] eq $field); 637 638 my $data_name = $data->[0]; 639 # Remove the any namespace if we are being told to ignore them 640 if($ignore_namespace) { 641 $data_name =~ s/^\w*\.//; 642 } 643 644 return $data->[1] if (scalar(@$data) >= 2 && $data_name eq $field); 624 645 } 625 646 … … 627 648 } 628 649 629 630 650 # returns a list of the form [value1, value2, ...] 631 651 sub get_metadata { 632 652 my $self = shift (@_); 633 my ($section, $field ) = @_;653 my ($section, $field, $ignore_namespace) = @_; 634 654 my ($data); 655 656 $ignore_namespace = 0 unless defined $ignore_namespace; 635 657 636 658 my $section_ptr = $self->_lookup_section($section); … … 641 663 } 642 664 665 # Remove the any namespace if we are being told to ignore them 666 if($ignore_namespace) { 667 $field =~ s/^\w*\.//; 668 } 669 643 670 my @metadata = (); 644 671 foreach $data (@{$section_ptr->{'metadata'}}) { 645 push (@metadata, $data->[1]) if ($data->[0] eq $field); 672 673 my $data_name = $data->[0]; 674 # Remove the any namespace if we are being told to ignore them 675 if($ignore_namespace) { 676 $data_name =~ s/^\w*\.//; 677 } 678 679 push (@metadata, $data->[1]) if ($data_name eq $field); 646 680 } 647 681
Note:
See TracChangeset
for help on using the changeset viewer.