BenHopkins has asked for the wisdom of the Perl Monks concerning the following question:
I'm sestting up TwigHandlers like this (partial code):
... and process_body_hl2 is pretty simple:my $twig = new XML::Twig( TwigHandlers => { 'byline' => \&byline, 'body.head/hedline' => \&hedline, 'body.content/p' => \&process_p, 'body.content/hl2' => \&process_body_hl2, 'body.content/block/p' => \&process_p, 'body.content/block/hl2' => \&process_body_hl2, 'body.content/table' => \&process_table, etc. etc.
Input looks like this:sub process_body_hl2 { my ($t, $hl2) = @_; my $para = crunch($hl2->text); $body .= "<p><b>$para</b></p>"; }
The output for that part comes out like this (this is a different format of xml from the input):<body.content> <hl2 style="section_head">SECTION HEAD</hl2> <hl2 style="subhead">subhead</hl2> <p/>
Where are the <b> tags? Later, the next hl2 in the body looks like this:<body.content> <p>SECTION HEAD</p><p>subhead</p>
And this one comes out the way it should:<p/> <hl2 style="subhead">2nd subhead</hl2>
Now, how come the first two did not work, but the subsequent one did?<p><b>2nd subhead</b></p><p>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: TwigHandlers not always called?
by mirod (Canon) on Jul 12, 2013 at 05:10 UTC | |
by BenHopkins (Sexton) on Jul 13, 2013 at 01:04 UTC | |
by mirod (Canon) on Jul 13, 2013 at 09:14 UTC |