Ignore:
Timestamp:
2015-01-09T14:24:10+13:00 (9 years ago)
Author:
Jeremy Symon
Message:

Moved xml i/o handling to the module for simplicity of use

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/package-kits/scripts/gs-servlet.pl

    r29674 r29678  
    99
    1010use lib 'perllib';
    11 use XML::Tidy;
     11use Greenstone::XML::Tidy;
    1212
    1313my $hash;
     
    3939        "Parses XML from a file into the internal state\n  input_file (- for STDIN)",
    4040        sub {
    41             my $file = shift @ARGV;
    42             my $new;
    43             if ($file eq '-') {
    44                 if (isatty *STDIN) {
    45                     print STDERR "Reading XML from STDIN. Press ^D to end\n";
    46                 }
    47                 $new = read_xml *STDIN;
    48             } else {
    49                 open FH, '<', $file;
    50                 $new = read_xml *FH;
    51                 close FH;
    52             }
     41            my $new = read_xml shift @ARGV;
    5342            # Append the new data to the current data
    5443            for my $key (keys %$new) {
     
    7362        "Writes the current internal state as XML to a file\n  output_file (- for STDOUT)",
    7463        sub {
    75             my $file = shift @ARGV;
    76             if ($file eq '-') {
    77                 write_xml $hash, *STDOUT;
    78             } else {
    79                 open FH, '>', $file;
    80                 write_xml $hash, *FH;
    81                 close FH;
    82             }
     64            write_xml $hash, shift @ARGV;
    8365        },
    8466        1,
Note: See TracChangeset for help on using the changeset viewer.