- Timestamp:
- 2015-01-07T11:06:08+13:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/package-kits/linux/files/servlet.pl
r29666 r29667 99 99 sub write_servlets { 100 100 my ($hash, $file) = @_; 101 open OUT, '>', $file; 101 my $OUT; 102 if ($file ne '-') { 103 open $OUT, '>', $file; 104 select $OUT; 105 } 102 106 sub open_tag { 103 107 my ($indent, $tag, $attr) = @_; 104 print OUT$indent, "<", $tag;108 print $indent, "<", $tag; 105 109 if (defined $attr) { 106 110 for my $key (sort keys %$attr) { 107 print OUT" ", $key, '="', $attr->{$key}, '"';108 } 109 } 110 print OUT">";111 print " ", $key, '="', $attr->{$key}, '"'; 112 } 113 } 114 print ">"; 111 115 } 112 116 sub write_xml { … … 116 120 my $val = $hash->{$key}; 117 121 $key eq '.value' && do { 118 print OUT$val, "\n";122 print $val, "\n"; 119 123 next; 120 124 }; … … 125 129 for (ref $element) { 126 130 /^HASH$/ && do { 127 print OUT"\n";131 print "\n"; 128 132 write_xml (" $indent", $element); 129 print OUT$indent, "</", $key, ">\n";133 print $indent, "</", $key, ">\n"; 130 134 last; 131 135 }; 132 print OUT$element, "</", $key, ">\n";136 print $element, "</", $key, ">\n"; 133 137 } 134 138 } … … 140 144 # it can be formatted on one line 141 145 if (scalar keys %$val == 2 and defined $val->{'.value'}) { 142 print OUT$val->{'.value'}, "</", $key, ">\n";146 print $val->{'.value'}, "</", $key, ">\n"; 143 147 } else { 144 print OUT"\n";148 print "\n"; 145 149 write_xml (" $indent", $val); 146 print OUT$indent, "</", $key, ">\n";150 print $indent, "</", $key, ">\n"; 147 151 } 148 152 last; 149 153 }; 150 154 open_tag ($indent, $key); 151 print OUT$val;152 print OUT"</", $key, ">\n";155 print $val; 156 print "</", $key, ">\n"; 153 157 } 154 158 } 155 159 } 156 160 write_xml ("", $hash); 157 close OUT; 158 } 161 if (defined $OUT) { 162 close $OUT; 163 } 164 select STDOUT; 165 } 166 # The code above is for generic XML read/writing 167 # The code below is specific to Greenstone's servlets.xml 159 168 160 169 my $hash;
Note:
See TracChangeset
for help on using the changeset viewer.