Subject: | passiing options to parsers not possible |
Hi,
I encountered this bug when i tried to use the ProtocolEncoding option of the expat parser. The parser function doesnt seem to pass on options to the _parser_* functions.
I made a quick fix that seem to work with the following code:
#-------------------------------------------------------------------#
# $p->parse(%options)
#-------------------------------------------------------------------#
sub parse {
my $self = shift;
my $parse_options = $self->get_options(@_);
local $self->{ParseOptions} = $parse_options;
if ($self->{Parent}) { # calling parse on a filter for some reason
return $self->{Parent}->parse($parse_options);
}
else {
my $method;
if (defined $parse_options->{Source}{CharacterStream} and $method = $self->can('_parse_characterstream')) {
warn("parse charstream???\n");
return $method->($self, $parse_options->{Source}{CharacterStream},$parse_options);
}
elsif (defined $parse_options->{Source}{ByteStream} and $method = $self->can('_parse_bytestream')) {
return $method->($self, $parse_options->{Source}{ByteStream},$parse_options);
}
elsif (defined $parse_options->{Source}{String} and $method = $self->can('_parse_string')) {
return $method->($self, $parse_options->{Source}{String},$parse_options);
}
elsif (defined $parse_options->{Source}{SystemId} and $method = $self->can('_parse_systemid')) {
return $method->($self, $parse_options->{Source}{SystemId},$parse_options);
}
else {
die "No _parse_* routine defined on this driver (if it a filter, remember to set the Parent property) [$self]";
}
}
}
(sidenote: XML::SAX::Expat has the same kind of problem in its _create_parser function, so if you use the expat parser to test this, you have to make a quick fix there too. I reported that to the XML::SAX::Expat bugtracking on CPAN.)
Feel free to contact me if needed,
Merijn van den Kroonenberg