--- nfo/perl/scripts/xupdate/xupdate.pl 2003/05/01 20:41:47 1.1 +++ nfo/perl/scripts/xupdate/xupdate.pl 2003/05/06 15:35:49 1.3 @@ -1,9 +1,16 @@ #!/usr/bin/perl ## ------------------------------------------------------------------------- -## $Id: xupdate.pl,v 1.1 2003/05/01 20:41:47 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 +## ## Revision 1.1 2003/05/01 20:41:47 joko ## initial commit, partly from joko/Scripts/xupdate/xupdate.pl. ## @@ -25,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 @@ -41,31 +50,41 @@ 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 { my $xupdate = XML::XUpdate::XSLT->new( - warnings => 1 + debug => 0, + warnings => 1, ); #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"; } }