- Timestamp:
- Apr 23, 2010, 12:15:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-Metadata-Config/lib/PS/IPP/Metadata/Config.pm
r15558 r27756 59 59 } 60 60 61 # Parse a list of METADATAs 62 sub parse_list 63 { 64 my $self = shift; # This parser 65 66 # Split input into separate METADATAs because the parser seems to take forever handling those together 67 my @whole = split /\n/, join( '', @_ ); # The whole input 68 my @single; # A single METADATA element 69 my @output; # Output 70 foreach my $value (@whole) { 71 push @single, $value; 72 if ($value =~ /^\s*END\s*$/) { 73 push @single, "\n"; 74 75 my $md = join("\n", @single); # Metadata to parse 76 my $parsed = $self->parse($md) or (carp "Unable to parse input: $md\n" and next); 77 (carp "More than one entry in input: $md\n" and next) if scalar @$parsed > 1; 78 my $metadata = shift @$parsed; # Metadata of interest 79 (carp "MD element is not of type METADATA: $md\n" and next) if $metadata->{class} ne "metadata"; 80 my $components = $metadata->{value}; # Components of metadata 81 my %hash; # Hash for entry 82 foreach my $comp (@$components) { 83 $hash{$comp->{name}} = $comp->{value}; 84 } 85 push @output, \%hash; 86 @single = (); 87 } 88 } 89 90 return \@output; 91 } 92 61 93 sub _merge_duplicates { 62 94 my ( $self, $tree ) = @_; … … 73 105 # stop if the prevous pass removed the last element and called redo 74 106 last unless defined $elem; 75 107 76 108 # recurse through nested metadata 77 109 if ( $elem->{class} eq "metadata" ) { … … 83 115 delete $elem->{multi}; 84 116 next; 85 } 117 } 86 118 87 119 if ( defined $names{ $elem->{name} } ) {
Note:
See TracChangeset
for help on using the changeset viewer.
