Skip Menu |

This queue is for tickets about the XML-SAX-Expat CPAN distribution.

Report information
The Basics
Id: 609
Status: open
Priority: 0/
Queue: XML-SAX-Expat

People
Owner: robin.berjon [...] gmail
Requestors: merijn [...] e-factory.nl
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



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
Hi, XML::SAX::Expat should *not* pass any options on, at least not that way. Some options which are generic enough ought to be added to the SAX spec (for the next upcoming edition) so that other parsers can use them as well. Non-generic options could be passed as Features but that would lock you into using this parser. If you could make a list of the options you'd see as useful/necessary, and of which are generic or not it'd help a hell of a lot :-) -- --darobin