Subject: | passing parser options not possible |
I encountered this bug when i tried to use the ProtocolEncoding option of the expat parser. The _create_parser function doesnt seem to pass on options to XML::Parser.
I made a quick fix that seem to work with the following code:
#-------------------------------------------------------------------#
# $p->_create_parser(\%options)
#-------------------------------------------------------------------#
sub _create_parser {
my $self = shift;
my $opt = shift;
die "ParserReference: parser instance ($self) already parsing\n"
if defined $self->{_InParse};
my $expat = XML::Parser->new(
Handlers => {
Init => sub { $self->_handle_init(@_) },
Final => sub { $self->_handle_final(@_) },
Start => sub { $self->_handle_start(@_) },
End => sub { $self->_handle_end(@_) },
Char => sub { $self->_handle_char(@_) },
Comment => sub { $self->_handle_comment(@_) },
Proc => sub { $self->_handle_proc(@_) },
CdataStart => sub { $self->_handle_start_cdata(@_) },
CdataEnd => sub { $self->_handle_end_cdata(@_) },
Unparsed => sub { $self->_handle_unparsed_entity(@_) },
Notation => sub { $self->_handle_notation_decl(@_) },
#ExternEnt
#ExternEntFin
Entity => sub { $self->_handle_entity_decl(@_) },
Element => sub { $self->_handle_element_decl(@_) },
Attlist => sub { $self->_handle_attr_decl(@_) },
Doctype => sub { $self->_handle_start_doctype(@_) },
DoctypeFin => sub { $self->_handle_end_doctype(@_) },
XMLDecl => sub { $self->_handle_xml_decl(@_) },
},%{$opt}
);
$self->{_InParse} = 1;
$self->{_NodeStack} = [];
$self->{_NSStack} = [];
$self->{_NSHelper} = XML::NamespaceSupport->new({xmlns => 1});
return $expat;
}
This will not fix the problem immediately because XML::SAX::Base has also the same kind of problem in the parse method. This is also easy to fix and i will report it to the XML::SAX::Base bug tracking on cpan.
If you have questions, just mail me.
Merijn van den Kroonenberg