# HG changeset patch # User insilmaril # Date 1138115389 0 # Node ID 96e7cd53125e0d5a5d1a417fede87c10adebae07 # Parent 2658342e3310d37c88be6c397f57cffa1c3d432f Introduced basic export to Open Document format diff -r 2658342e3310 -r 96e7cd53125e scripts/niceXML --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/niceXML Tue Jan 24 15:09:49 2006 +0000 @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# +# Hack to make single-line XML file easier to read by using indention +# +# (c) Uwe Drechsel +# +# License: GPL + +my $filename =shift; +my $s; +open (INFILE, "<$filename") || + die "Could not read $filename."; +$s=join("\n",); + +$s=~s/>/>\n/gm; + +my @lines=split ("\n",$s); +my $i=0; +my $is=""; + +foreach (@lines) +{ + if (!/<.*?\/>/) + { + if (/<\//) + { + # Closing tag + $i--; + if ($i<0) {$i=0}; + $is=indent($i); + print "$is$_\n"; + } else + { + if (/<(?!\?)/) # ignore + { + # Opening tag + print "$is$_\n"; + $i++; + $is=indent($i); + } else + { + # empty lines etc + print "$is$_\n"; + } + } + } else + { + # Ignor single tags <../> + print "$is$_\n"; + } +} +print "\n"; +exit; + +sub indent() +{ + my $size=shift; + my $s=""; + for ($i=0; $i<$size; $i++) + { + $s=$s." "; + } + return $s; +}