SPUG: can't die() from XML::Parser handlers?
ced at carios2.ca.boeing.com
ced at carios2.ca.boeing.com
Mon Sep 17 12:44:19 CDT 2001
I don't know XML and haven't tried either interface. However,
if you're not heavily invested in XML::Parser, I do recall
Dan Brian at Open Source discouraged writing directly
to the XML::Parser API. He recommended XML::LibXML, a newer,
reportedly faster interface based on the gnome libxml2 library.
Rgds,
--
Charles DeRykus
> I've discovered what I consider very strange behaviour in XML::Parser:
>
> I'm using the 'Subs' style of parsing, like this:
>
>
> use XML::Parser;
>
> # ....
>
> my $parser = new XML::Parser(
> Style => 'Subs',
> Pkg => 'my_Handlers',
> );
> $parser->parsefile( $SOME_XML_FILE );
> #....
>
> package my_Handlers;
>
> sub table {
> my $table_id;
>
> # ... some stuff to find the "id" attribute
>
> die( "table must have an id attribute" ) unless defined $table_id;
>
> # ... more stuff
> }
>
> __END__
>
> Now, it turned out that due to an error in the XML file, $table_id
> was in fact undef inside table(). The weird thing is that the die()
> call isn't causing the program to die: it just exits the handler but
> keeps on going parsing the XML file as if nothing had happened. I
> can only assume that XML::Parser is calling the handlers from inside
> an eval block (which would make sense) and then ignoring the error
> messages (which doesn't make any sense at all).
>
> I don't get it. Is this a bug or some sort of feature that I'm
> understanding? How can I get the handlers to raise a fatal
> exception? (Of course I can think of plenty of kludgey work-arounds,
> but nothing elegant.)
>
>
>
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list