> I'm curious though, why you've chosen to implement it as a handler for 
> XML::Parser rather than as a SAX Handler (or even better, a Filter)?  What 
> SAX buys (among other things) is the ability for folks to invisibly use 
> whatever XML parser is installed, including a pure Perl implementation.
> 
> Doing Petal as a SAX Filter would mean that it would be totally easy to add 
> it to the mix in things like AxKit and custom SAX pipeline publishing 
> systems. So, doing complex, multi-stage transformations like 
> My::NonXML::SAXGenerator -> Petal -> SomeXSLT -> SomeOtherXSLT come for 
> free.

Interesting stuff... And I think it would be quite easy to implement!

At the moment Petal features two XML event generators:

Petal::Parser::XMLWrapper (based on XML::Parser)
Petal::Parser::HTMLWrapper (based on HTML::TreeBuilder)

I suppose I could write a

Petal::Parser::SAXWrapper... it would be quite trivial to generate the
XML::Parser events from that :-)

My only problem deals with template caching. Currently Petal does the
following:

* Generate events to build a 'canonical' template file
* Convert that template file to Perl code
** Cache the Perl code onto disk
* Compiles the Perl code as a subroutine
** Caches the subroutine in memory

Cache is kept fresh using the template file mtime() information.

If I had a SAX event parser, then maybe caching could be a bit
troublesome?

Maybe what I really need would be to write something a bit more generic,
i.e.

my $template = new Petal (
    event_generator => $event_generator,
    cache_key       => $cache_key,
    cache_expires   => \&coderef
);

I do not have much experience with SAX and pipelines or things, but if
you feel like looking at the code and make sensible architectural suggestions to
make Petal as generic and modular as possible then I'll be quite happy
to implement them :-)


> Anyway, just random thoughts, really. Petal seems nice and it seems a shame 
> to lock it in the XML::Parser-based-one-off jail.

Well, it's not *really*. Take a look at Petal::Parser::HTMLWrapper,
you'll see it's pretty straightforward :-)

Oh by the way, Petal 0.2 is out, it fixes a stupid critical bug and a
couple of documentation bugs...

http://search.cpan.org/doc/JHIVER/Petal.0.2/lib/Petal.pm

Best regards,
-- 
IT'S TIME FOR A DIFFERENT KIND OF WEB
================================================================
  Jean-Michel Hiver - Software Director
  [EMAIL PROTECTED]
  +44 (0)114 255 8097
================================================================
                                      VISIT HTTP://WWW.MKDOC.COM

Reply via email to