I have a SAX filter that wants to insert some content into the current stream for downstream handlers to process (i.e.: add node to the output). How can I do that? I was thinking, maybe I could create a new pipeline (connected to $self) and call parse_string()on it, but this did not work:
Trying to pop context without push context at /usr/lib/perl5/vendor_perl/5.10/XML/NamespaceSupport.pm
The handler looks something like this:
package My::Filter;
use base qw(XML::SAX::Base);
sub end_element {
my $self = shift;
if($insertStuff) {
XML::SAX::ParserFactory->parser( Handler => $self)->parse_string("<new>content</new>");
}
$self->SUPER::start_element($element);
}
source
share