--- a/common/tools/mergeXML.pl Mon Dec 07 15:22:47 2009 +0000
+++ b/common/tools/mergeXML.pl Mon Dec 07 17:21:55 2009 +0000
@@ -18,6 +18,11 @@
use XML::Parser;
use Getopt::Long;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use XML::Printer;
+
# Read option arguments
my $howtoString;
my $xslLink;
@@ -61,7 +66,7 @@
# Output total tree
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print "<?xml-stylesheet type=\"text/xsl\" href=\"$xslLink\"?>\n" if $xslLink;
-printTree($outTree->[0]);
+XML::Printer::printTree($outTree->[0]);
print "\n";
exit(0);
@@ -147,47 +152,4 @@
return undef;
}
-sub printTree
-{
- my $tree = shift or die;
- die unless ref $tree;
- my $tagName = ref $tree;
- $tagName =~ s{^main::}{};
- if ($tagName eq "Characters")
- {
- print $tree->{Text};
- return;
- }
-
- print "<$tagName";
-
- foreach my $attr (
- sort
- grep {
- ! ref $tree->{$_}
- }
- keys %$tree)
- {
- print " $attr=\"$tree->{$attr}\"";
- }
-
- my $children = $tree->{Kids};
- if (scalar @$children)
- {
- print ">";
- foreach my $child (@$children)
- {
- printTree($child);
- }
- print "</$tagName";
- }
- else
- {
- print "/"
- }
-
- print ">";
-}
-
-