--- nfo/perl/scripts/xupdate/xupdate.pl 2003/05/01 23:43:58 1.2 +++ nfo/perl/scripts/xupdate/xupdate.pl 2003/05/06 15:35:49 1.3 @@ -1,9 +1,13 @@ #!/usr/bin/perl ## ------------------------------------------------------------------------- -## $Id: xupdate.pl,v 1.2 2003/05/01 23:43:58 joko Exp $ +## $Id: xupdate.pl,v 1.3 2003/05/06 15:35:49 joko Exp $ ## ------------------------------------------------------------------------- ## $Log: xupdate.pl,v $ +## Revision 1.3 2003/05/06 15:35:49 joko +## updated pod and comments +## played with xml document rewriting as post xupdate operation to polish the payload +## ## Revision 1.2 2003/05/01 23:43:58 joko ## required debugging flag ## @@ -28,8 +32,10 @@ =head3 Todo - o mimic interface from already established "xupdate.pl" - o replace shortcuts::files through File::Butler? + o mimic interface from already established "xupdate.pl" written by Petr Pajas + o replace shortcuts::files through File::Butler? + o write out result document into file named "wd_result.xml" + o use nice (human readable) xml formatting there with some XML::Writer??? =cut @@ -44,9 +50,10 @@ use lib '../../libs'; } -use XML::XUpdate::XSLT; -use shortcuts::files qw( f2s ); use Data::Dumper; +use XML::XUpdate::XSLT; + +use shortcuts::files qw( f2s s2f ); sub main { @@ -58,18 +65,26 @@ #print Dumper($xupdate); - # open required files + # Open example files from Working Draft. $xupdate->open_document( f2s("wd_document.xml") ); $xupdate->open_xupdate( f2s("wd_xupdate.xml") ); + # Apply xupdate to document, convert to raw xml and dump this to STDOUT. $xupdate->process(); - my $result = $xupdate->toString(); + my $result; + + # Produce human readable format, using indentation and stuff. + #$result = $xupdate->toString( rewrite => 1, using => "PerlSAX", mode => "readable" ); + $result = $xupdate->toString( rewrite => 0, using => "XMLParser", mode => "readable" ); + # Produces canonical format, just a long line. + #$result = $xupdate->toString("canonical"); # some error checking ... if ($result) { - print $result, "\n"; + print STDOUT $result, "\n"; + #s2f("wd_document.xml", $result); } else { - print "No result.", "\n"; + print STDERR "$0: No result or error while applying XUpdate payload to XML document.", "\n"; } }