# for more information.
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
# xmlpp: XML pretty printing
#
use Fcntl;
use Getopt::Std;
-use vars qw($opt_h $opt_H $opt_s $opt_z $opt_t $opt_e $opt_S $opt_c $opt_n);
+use vars qw($opt_h $opt_H $opt_s $opt_z $opt_t $opt_e $opt_S $opt_c $opt_n $opt_l);
my $indent=0;
my $textContent='';
my $inAnnotation = 0;
-if (!getopts('nzhHsteSc') or $opt_h) {
+if (!getopts('nzhHsteScl:') or $opt_h) {
usage();
}
+my $indentSize = $opt_l || 2;
+
if ($opt_s){
# expect to find attributeOrdering.txt file in same directory
$output .= "\n";
}
- $output .= " " x $indent;
+ $output .= " " x ($indent * $indentSize);
$output .= "<$s";
my @k = keys %attr;
}
if ($splitAttributes) {
- $output .= "\n"." " x $indent." ";
+ $output .= "\n"." " x ($indent * $indentSize) ." ";
}
if ($attr{$attr} =~ /'/) {
$output .= " $attr=\"$attr{$attr}\"";
}
}
if ($splitAttributes and @k) {
- $output .= "\n"." " x $indent;
+ $output .= "\n"." " x ($indent * $indentSize);
}
if ($selfclose) {
$output .= " />";
printContent($textContent);
if ($lastTag == 0) {
$output .= "\n";
- $output .= " " x $indent;
+ $output .= " " x ($indent * $indentSize);
}
$output .= "</$s>";
$textContent = '';
-c place comments on new line.
-n normalise whitespace (remove leading and trailing whitespace from nodes
with text content.
-
+ -l <num> Indent each level by <num> spaces [default: 2]
EOF
exit 1;
}