[Petal] Specifying a parser

William McKee william@knowmad.com
Wed, 31 Jul 2002 17:04:25 -0400


So all of this messing with the XML::Parser lib has got me wondering whether the 
$Petal::PARSER setting really works. If it was set to HTML, then it seems to me that 
Petal should have never been calling the eval funtion in XML::Parser.

I poked around in Petal.pm and found the _canonicalize routine to be the one which 
uses the PARSER setting (via a call to _parser_type). It seems to me that the 
following line (#351 in Petal.pm) should never get the XML parser if I've set 
PARSER to HTML:

my $parser_module_name = shift || $PARSERS->{$parser_type};


Since that doesn't seem to be working due to my problems with expat, I placed the 
following test code after that line:

warn "XML parser in use - $parser_module_name!" if $parser_module_name =~ /X
ML/i;

Now, if I've set PARSER to HTML, I would think that this line should not be called. I 
may be wrong in this belief but in my tests, it did get called.

My concern is not with segfaults anymore but with performance. If I know that none 
of my templates are valid xml, then there's no point in running the expat parser to 
tell Petal to use HTML. In mod_perl, it should only do this once but when I'm testing, 
it appears to be rebuilding the template often enough to be annoying.

Is it me or is it Petal?

Thanks,
William
-- 
 Lead Developer
 Knowmad Services Inc. || Internet Applications & Database Integration
 http://www.knowmad.com