| 4 |
## $Id$ |
## $Id$ |
| 5 |
## ------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
| 6 |
## $Log$ |
## $Log$ |
| 7 |
|
## Revision 1.3 2003/05/06 15:35:49 joko |
| 8 |
|
## updated pod and comments |
| 9 |
|
## played with xml document rewriting as post xupdate operation to polish the payload |
| 10 |
|
## |
| 11 |
|
## Revision 1.2 2003/05/01 23:43:58 joko |
| 12 |
|
## required debugging flag |
| 13 |
|
## |
| 14 |
## Revision 1.1 2003/05/01 20:41:47 joko |
## Revision 1.1 2003/05/01 20:41:47 joko |
| 15 |
## initial commit, partly from joko/Scripts/xupdate/xupdate.pl. |
## initial commit, partly from joko/Scripts/xupdate/xupdate.pl. |
| 16 |
## |
## |
| 32 |
|
|
| 33 |
=head3 Todo |
=head3 Todo |
| 34 |
|
|
| 35 |
o mimic interface from already established "xupdate.pl" |
o mimic interface from already established "xupdate.pl" written by Petr Pajas |
| 36 |
o replace shortcuts::files through File::Butler? |
o replace shortcuts::files through File::Butler? |
| 37 |
|
o write out result document into file named "wd_result.xml" |
| 38 |
|
o use nice (human readable) xml formatting there with some XML::Writer??? |
| 39 |
|
|
| 40 |
|
|
| 41 |
=cut |
=cut |
| 50 |
use lib '../../libs'; |
use lib '../../libs'; |
| 51 |
} |
} |
| 52 |
|
|
|
use XML::XUpdate::XSLT; |
|
|
use shortcuts::files qw( f2s ); |
|
| 53 |
use Data::Dumper; |
use Data::Dumper; |
| 54 |
|
use XML::XUpdate::XSLT; |
| 55 |
|
|
| 56 |
|
use shortcuts::files qw( f2s s2f ); |
| 57 |
|
|
| 58 |
|
|
| 59 |
sub main { |
sub main { |
| 60 |
|
|
| 61 |
my $xupdate = XML::XUpdate::XSLT->new( |
my $xupdate = XML::XUpdate::XSLT->new( |
| 62 |
warnings => 1 |
debug => 0, |
| 63 |
|
warnings => 1, |
| 64 |
); |
); |
| 65 |
|
|
| 66 |
#print Dumper($xupdate); |
#print Dumper($xupdate); |
| 67 |
|
|
| 68 |
# open required files |
# Open example files from Working Draft. |
| 69 |
$xupdate->open_document( f2s("wd_document.xml") ); |
$xupdate->open_document( f2s("wd_document.xml") ); |
| 70 |
$xupdate->open_xupdate( f2s("wd_xupdate.xml") ); |
$xupdate->open_xupdate( f2s("wd_xupdate.xml") ); |
| 71 |
|
|
| 72 |
|
# Apply xupdate to document, convert to raw xml and dump this to STDOUT. |
| 73 |
$xupdate->process(); |
$xupdate->process(); |
| 74 |
my $result = $xupdate->toString(); |
my $result; |
| 75 |
|
|
| 76 |
|
# Produce human readable format, using indentation and stuff. |
| 77 |
|
#$result = $xupdate->toString( rewrite => 1, using => "PerlSAX", mode => "readable" ); |
| 78 |
|
$result = $xupdate->toString( rewrite => 0, using => "XMLParser", mode => "readable" ); |
| 79 |
|
# Produces canonical format, just a long line. |
| 80 |
|
#$result = $xupdate->toString("canonical"); |
| 81 |
|
|
| 82 |
# some error checking ... |
# some error checking ... |
| 83 |
if ($result) { |
if ($result) { |
| 84 |
print $result, "\n"; |
print STDOUT $result, "\n"; |
| 85 |
|
#s2f("wd_document.xml", $result); |
| 86 |
} else { |
} else { |
| 87 |
print "No result.", "\n"; |
print STDERR "$0: No result or error while applying XUpdate payload to XML document.", "\n"; |
| 88 |
} |
} |
| 89 |
|
|
| 90 |
} |
} |