@@ -77,12 +77,12 @@ sub post_all :prototype(&) {
77
77
# # whether the element described in
78
78
# # core-parameter hash %CPs matches.
79
79
# # @params optional when If provided, when to run the action:
80
- # # HI, BYE, or CIAO. Default is HI .
80
+ # # HI, BYE, or CIAO. Default is BYE .
81
81
sub add_to_worklist {
82
82
my $sandbox = _sandbox or croak " Can't find sandbox" ;
83
- # say "add_to_worklist args: ", Dumper(\@_);
84
83
my ($drAction , $refPattern , $when ) = @_ ;
85
- $when = $when // HI; # only on entry, by default
84
+
85
+ $when = $when // BYE; # only on exit, by default
86
86
$refPattern = \( my $temp = $refPattern ) unless ref ($refPattern );
87
87
88
88
push @{$sandbox -> worklist}, [$refPattern , $drAction , $when ];
@@ -98,42 +98,41 @@ sub run :prototype(&;$) {
98
98
return @_ ;
99
99
} # run()
100
100
101
- # pattern-first style - on {} run {} [when (default HI)];
101
+ # pattern-first style - on {} run {} [when];
102
+ # The default [when] is BYE so that the text content of the node is
103
+ # available --- at HI, all you have are the attributes.
102
104
sub on :prototype(&@) {
103
105
my ($drMakeMatcher , $drAction , $when ) = @_ ;
104
106
105
- # say "MakeMatcher: ", Dumper($drMakeMatcher);
106
107
my $matcher = &$drMakeMatcher ;
107
- # say "Matcher: ", Dumper($matcher);
108
-
109
108
@_ =($drAction , $matcher , $when );
110
109
goto &add_to_worklist;
111
110
} # on()
112
111
113
- # pattern-first style, sugar for symmetry with whenever() and leaving ()
114
- sub entering :prototype(&@) {
112
+ # pattern-first style, sugar for symmetry with whenever() and entering ()
113
+ sub leaving :prototype(&@) {
115
114
goto &on
116
115
} # entering()
117
116
118
- # pattern-first style, common implementation for BYE and CIAO
119
- sub _leaving_whenever_impl {
117
+ # pattern-first style, common implementation for HI and CIAO
118
+ sub _entering_whenever_impl {
120
119
croak " Too many arguments" if $#_ >2;
121
120
my ($when , $drMakeMatcher , $drAction ) = @_ ;
122
121
my $matcher = &$drMakeMatcher ;
123
122
@_ =($drAction , $matcher , $when );
124
123
goto &add_to_worklist;
125
124
} # _leaving_whenever_impl()
126
125
127
- # pattern-first style, specific to leaving nodes (BYE ) - leaving {} run {};
128
- sub leaving :prototype(&@) {
129
- unshift @_ , BYE ;
130
- goto &_leaving_whenever_impl ;
126
+ # pattern-first style, specific to entering nodes (HI ) - entering {} run {};
127
+ sub entering :prototype(&@) {
128
+ unshift @_ , HI ;
129
+ goto &_entering_whenever_impl ;
131
130
} # leaving()
132
131
133
132
# pattern-first style, specific to hitting nodes (CIAO) - whenever {} run {};
134
133
sub whenever :prototype(&@) {
135
134
unshift @_ , CIAO;
136
- goto &_leaving_whenever_impl ;
135
+ goto &_entering_whenever_impl ;
137
136
} # whenever()
138
137
139
138
# }}}1
@@ -232,11 +231,11 @@ XML::Axk::Core::L1 - ack-like XML processor, language 1
232
231
233
232
L1
234
233
on { xpath(q<//item>) } run {say "$NOW: " . $E->getTagName}, CIAO
235
- # "CIAO" can also be "HI" or "BYE" (default HI ).
236
- # "entering " is a synonym for "on" with no HI/BYE/CIAO.
234
+ # "CIAO" can also be "HI" or "BYE" (default BYE ).
235
+ # "leaving " is a synonym for "on" with no HI/BYE/CIAO.
237
236
whenever { xpath(q<//item>) } run {say "$NOW: " . $E->getTagName};
238
237
# the same as the "on ... CIAO" line
239
- leaving { xpath(q<//item>) } run {say "$NOW: " . $E->getTagName};
238
+ entering { xpath(q<//item>) } run {say "$NOW: " . $E->getTagName};
240
239
241
240
=head1 PATTERNS AND ACTIONS
242
241
@@ -256,7 +255,8 @@ When the node is first reached, before any of its children are processed
256
255
257
256
=item C<BYE >
258
257
259
- After all of the node's children have been processed.
258
+ After all of the node's children have been processed. This is the default
259
+ so that you have the text content of the node available for inspection.
260
260
261
261
=item C<CIAO >
262
262
@@ -290,15 +290,17 @@ When an C<< <action> >> is running, it has access to predefined variables
290
290
that hold the state of the element being matched. This is similar to C<$0 > ,
291
291
C<$1 > , ... in awk.
292
292
293
+ At present, L1 uses L<XML::DOM> .
294
+
293
295
=over
294
296
295
297
=item B<$D >
296
298
297
- The current XML document
299
+ The current XML document ( L<XML::DOM::Document> )
298
300
299
301
=item B<$E >
300
302
301
- The XML element that was matched
303
+ The XML element that was matched ( L<XML::DOM::Element> )
302
304
303
305
=item B<$NOW >
304
306
0 commit comments