ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: Proposal: SAX filter for conditional XML
by Grant McLean other posts by this author
Jun 6 2007 3:43PM messages near this date
view in the new Beta List Site
Re: Proposal: SAX filter for conditional XML | Re: Proposal: SAX filter for conditional XML
& XSLT On Wed, 2007-06-06 at 22:09 +0100, Paul LeoNerd Evans wrote: 
>  On Sun, 3 Jun 2007 15:11:02 +0100
>  Paul LeoNerd Evans <leonerd@[...].uk> wrote:
>  
>  > I couldn't find anything on CPAN that looked like it does this already,
>  > so I would like to propose to create such a module; likely called
>  > 
>  >   XML::Filter::Conditional
>  > 
>  > unless anyone has any objections, or better suggestions.
>  
>  Given the complete lack of any objection, I have started writing up the
>  code with a full CPAN wrapper around it; test scripts and the like.

I did give your question some thought, but failed to come up with a
better name.  There is some conceptual overlap with the PETAL templating
tool.  If your filter acquired some of PETAL's other functionality then
it might outgrow the name 'Conditional'.  I do like the idea of
delegating the evaluation of the condition to the user's Perl code. 

>  I've not managed to find a particularly nice way of doing the tests; the
>  best so far I can do, is to build an array of all the method calls the
>  'consumer' received, then run lots of assertions on the values in that
>  array - see attached files.
>  
>  Is this a good idea? Does anyone have any better ways of doing this?

I have used that approach and it's not without traps.  If you focus on
just the method calls you care about then you should be OK, but the
different SAX parsers do have subtle differences in the detail and order
of the events they generate. 

>  I wanted to avoid pulling in XML::SAX::Writer and asserting on the built
>  strings, because this seemed to me to have a number of issues with it.

I'd be inclined towards a solution based around SAX writer and using
XPath for your assertions.  Rather than pull in the writer module, you
could just make your test conditional on the availability of
XML::SAX::Writer and a suitable XPath engine.  Anyone who was seriously
using the module is likely to have both.  But if they didn't then the
tests would simply be skipped.

Cheers
Grant


_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Paul LeoNerd Evans
Paul LeoNerd Evans
Paul LeoNerd Evans
Grant McLean
Paul LeoNerd Evans

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved