#!/iw/perl/current/bin/perl # # file: fix-xml # desc: post-fix XML conversion results # eval 'exec /iw/perl/current/bin/perl -s $0 ${1+"$@"}' if 0; use strict; use vars qw($VERSION $RELEASE); # # current module verion my $Id =<<'EoI'; # $Id: //depot/isms/skulker/cbd/1.1/bin/fix-xml#3 $ EoI # my $RELEASE = sprintf("%d", $Id =~ /^# \$Id: .*#(\d+)/); my $VERSION = "1.1"; BEGIN { my $iw_root = ($ENV{IW}) ? $ENV{IW} : "/iw"; my $cbd_root = "$iw_root/skulker/cbd/current"; # where we find our local libraries my($libdir) = "$cbd_root/lib"; if ( -d $libdir) { unshift(@INC, $libdir); } # CBD XML support require 'cbd-xml.pl'; } # we want perl 5.00x or later require 5.004; # who am i? my $prog; ($prog = $0) =~ s#.*/##; # for processing command line options use Getopt::Std; # process command line options, if any use vars qw($opt_D); getopts('D:'); # debug mode? my($debug) = defined($opt_D) ? $opt_D : 0; FILE: foreach my $file (@ARGV) { my(@submission) = (); print STDERR "Processing $file ...\n" if ($debug); open(IN, "$file") || die "$prog: error reading $file: $!\n"; # slurp in the whole file while () { chomp; # remove XML declaration tag next if (/^<\?xml version=/); # clean up XML converter output s@><@>\n<@g; # clean up tags at start/end of lines s@^<(/?)([^>]+)>(.+)$@<$1$2>\n$3@g; s@^(.+)<(/?)([^>]+)>$@$1\n<$2$3>@g; push(@submission, split(/\n/)) ; } close(IN); # output file to use my($ofile) = $file; $ofile .= ".fixed" if ($debug); # additional clean up post_parse(\@submission); # write the (possibly) modified content open(OUT, ">$ofile") || die "$prog: error writing $ofile: $!\n"; print OUT join("\n", @submission), "\n"; } exit 0; # # post parse submission for additional clean up and tagging # sub post_parse { my($data) = shift; 0; } =head1 NAME fix-xml - Clean up 'sx' output =head1 PACKAGE CBD::fixxml =head1 REQUIRES Perl, version 5.001 or higher =head1 DESCRIPTION Performs fixes to the XML file produced by 'sx'. =over 3 =item usage: fix-xml Example: fix-xml 01NO99.xml =back =head1 COPYRIGHT Copyright 1999 Invisible Worlds =head1 AUTHOR CBD::fixxml was written by Gautam Yegnanarayan . =cut