Changeset 29679 for main/trunk/package-kits/scripts/gs-servlet.pl
- Timestamp:
- 2015-01-09T14:50:58+13:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/package-kits/scripts/gs-servlet.pl
r29678 r29679 11 11 use Greenstone::XML::Tidy; 12 12 13 my $hash ;13 my $hash = Hash::Ordered->new; 14 14 my %commands; 15 15 # Command structure: … … 32 32 'Clears the internal state', 33 33 sub { 34 undef $hash; 35 $hash = {}; 34 $hash = Hash::Ordered->new; 36 35 } 37 36 ], … … 41 40 my $new = read_xml shift @ARGV; 42 41 # Append the new data to the current data 43 for my $key (keys %$new) { 44 if ($key eq '.attr' and exists $hash->{'.attr'}) { 45 for my $attr ($new->{'.attr'}) { 46 $hash->{'.attr'}->{$attr} = $new->{'.attr'}->{$attr}; 42 for my $key ($new->keys) { 43 if ($key eq '.attr' and $hash->exists ('.attr')) { 44 my $existing_attr = $hash->get ('.attr'); 45 my $new_attr = $new->get ('.attr'); 46 for my $attr ($new_attr->keys) { 47 $existing_attr->set ($attr => $new_attr->get ($attr)); 47 48 } 48 } elsif (exists $hash->{$key}) { 49 if (ref $hash->{$key} ne 'ARRAY') { 50 $hash->{$key} = [ $hash->{$key} ]; 49 } elsif ($hash->exists ($key)) { 50 my $existing = $hash->get ($key); 51 if (ref $existing ne 'ARRAY') { 52 $existing = [ $existing ]; 53 $hash->set ($key => $existing); 51 54 } 52 push @{$hash->{$key}}, 53 (ref $new->{$key} eq 'ARRAY' ? @{$new->{$key}} : $new->{$key}); 55 my $new_val = $new->get ($key); 56 push @{$existing}, 57 (ref $new_val eq 'ARRAY' ? @{$new_val} : $new_val); 54 58 } else { 55 $hash-> {$key} = $new->{$key};59 $hash->set ($key => $new->get ($key)); 56 60 } 57 61 }
Note:
See TracChangeset
for help on using the changeset viewer.