1 |
#!/usr/bin/perl |
2 |
|
3 |
## ------------------------------------------------------------------------- |
4 |
## $Id: xupdate.pl,v 1.2 2003/05/01 23:43:58 joko Exp $ |
5 |
## ------------------------------------------------------------------------- |
6 |
## $Log: xupdate.pl,v $ |
7 |
## Revision 1.2 2003/05/01 23:43:58 joko |
8 |
## required debugging flag |
9 |
## |
10 |
## Revision 1.1 2003/05/01 20:41:47 joko |
11 |
## initial commit, partly from joko/Scripts/xupdate/xupdate.pl. |
12 |
## |
13 |
## ------------------------------------------------------------------------- |
14 |
|
15 |
|
16 |
=pod |
17 |
|
18 |
|
19 |
=head1 NAME |
20 |
|
21 |
xupdate.pl |
22 |
|
23 |
|
24 |
=head2 Description |
25 |
|
26 |
Please visit "perldoc XML::XUpdate::XSLT". |
27 |
|
28 |
|
29 |
=head3 Todo |
30 |
|
31 |
o mimic interface from already established "xupdate.pl" written by Petr Pajas |
32 |
o replace shortcuts::files through File::Butler? |
33 |
o write out result document into file named "wd_result.xml" |
34 |
o use nice (human readable) xml formatting there with some XML::Writer??? |
35 |
|
36 |
|
37 |
=cut |
38 |
|
39 |
|
40 |
package main; |
41 |
|
42 |
use strict; |
43 |
use warnings; |
44 |
|
45 |
BEGIN { |
46 |
use lib '../../libs'; |
47 |
} |
48 |
|
49 |
use Data::Dumper; |
50 |
use XML::XUpdate::XSLT; |
51 |
|
52 |
use shortcuts::files qw( f2s s2f ); |
53 |
|
54 |
|
55 |
sub main { |
56 |
|
57 |
my $xupdate = XML::XUpdate::XSLT->new( |
58 |
debug => 0, |
59 |
warnings => 1, |
60 |
); |
61 |
|
62 |
#print Dumper($xupdate); |
63 |
|
64 |
# Open example files from Working Draft. |
65 |
$xupdate->open_document( f2s("wd_document.xml") ); |
66 |
$xupdate->open_xupdate( f2s("wd_xupdate.xml") ); |
67 |
|
68 |
# Apply xupdate to document, convert to raw xml and dump this to STDOUT. |
69 |
$xupdate->process(); |
70 |
my $result; |
71 |
|
72 |
# Produce human readable format, using indentation and stuff. |
73 |
#$result = $xupdate->toString( rewrite => 1, using => "PerlSAX", mode => "readable" ); |
74 |
$result = $xupdate->toString( rewrite => 0, using => "XMLParser", mode => "readable" ); |
75 |
# Produces canonical format, just a long line. |
76 |
#$result = $xupdate->toString("canonical"); |
77 |
|
78 |
# some error checking ... |
79 |
if ($result) { |
80 |
print STDOUT $result, "\n"; |
81 |
#s2f("wd_document.xml", $result); |
82 |
} else { |
83 |
print STDERR "$0: No result or error while applying XUpdate payload to XML document.", "\n"; |
84 |
} |
85 |
|
86 |
} |
87 |
|
88 |
main(); |
89 |
print "ready.", "\n"; |
90 |
|
91 |
1; |
92 |
__END__ |