1STAG-HANDLE(1) User Contributed Perl Documentation STAG-HANDLE(1)
2
3
4
6 stag-handle - streams a stag file through a handler into a writer
7
9 stag-handle -w itext -c my-handler.pl myfile.xml > processed.itext
10 stag-handle -w itext -p My::Parser -m My::Handler myfile.xml > processed.itext
11
13 will take a Stag compatible format (xml, sxpr or itext), turn the data
14 into an event stream passing it through my-handler.pl
15
16 -help|h
17 shows this document
18
19 -module|m PERLMODULE
20 A module that is used to transform the input events the module
21 should inherit from Data::Stag::BaseHandler
22
23 -unit|u NODE_NAME
24 (you should always use this option if you specify -m)
25
26 this is the unit that gets passed to the handler/transformer. this
27 will get set automatically if you use the the -c, -s or -t options
28
29 multiple units can be set
30
31 -u foo -u bar -u boz
32
33 -writer|w WRITER
34 writer for final transformed tree; can be xml, sxpr or itext
35
36 -module|m MODULE
37 perl modules for handling events
38
39 -codefile|c FILE
40 a file containing a perlhashref containing event handlers - see
41 below
42
43 -sub|s PERL
44 a perl hashref containing handlers
45
46 -trap|t ELEMENT=SUB
47
49 unix> cat my-handler.pl
50 {
51 person => sub {
52 my ($self, $person) = @_;
53 $person->set_fullname($person->get_firstname . ' ' .
54 $person->get_lastname);
55 $person;
56 },
57 address => sub {
58 my ($self, $address) = @_;
59 # remove addresses altogether from processed file
60 return;
61 },
62 }
63
65 Hey! The above document had some coding errors, which are explained
66 below:
67
68 Around line 138:
69 =over should be: '=over' or '=over positive_number'
70
71
72
73perl v5.38.0 2023-07-20 STAG-HANDLE(1)