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: XML::SAX::Machines - calling widget methods
by Barrie Slaymaker other posts by this author
Feb 14 2002 6:53PM messages near this date
view in the new Beta List Site
Re: XML::SAX::Machines - calling widget methods | RE: Can't install XML::LibXML even though I have libxml2-2.4.9
On Thu, Feb 14, 2002 at 11:08:21AM -0500, Aaron Straup Cope wrote:
>  
>  If I can call the constructor in the pipeline, is there any reason why I
>  couldn't do this :

One nit is that

      "XML::Filter::XSLT-> new()->set_stylesheet_uri('my_pdflib.xsl')",

is not a class name, which is what machines expect plain scalars to be.
I could make plain strings be evalled, I suppose, but there are several
ways to solve this in lieu of such magic.  I'm vaguely for some such
magic because I'd like to enable machines to read the XML they generate
with generate_description() so machines can be specified in XML, but I'm
not sure a simple eval("") of the string is quite right for that.

Matt's already pointed out one alternative; here's another that
leverages the fact that machines name their parts:

    my $machine = Pipeline(
         "XML::Filter::XSLT",
         "XML::Filter::PDF",
         $pdf_file,
       );
  
    $machine-> Intake->set_stylesheet_uri("my_pdflib.xsl");
    #
    # could also do one of:
    #
    #   $machine-> Stage_0->set_stylesheet_uri("my_pdflib.xsl");
    #
    #   $machine-> find_part( "Intake"  )->set_stylesheet_uri("my_pdflib.xsl");
    #   $machine-> find_part( "Stage_0" )->set_stylesheet_uri("my_pdflib.xsl");
    #   $machine-> find_part( 0         )->set_stylesheet_uri("my_pdflib.xsl");
    #
   
    $machine-> parse_uri($xml_file);

You can also leverage the pure cleansing power of Perl like so:

    my $machine = Pipeline(
         ( my $xslt = XML::Filter::XSLT-> new() ),
         "XML::Filter::PDF",
         $pdf_file,
       );
  
    $xslt-> set_stylesheet_uri("my_pdflib.xsl");
   
    $machine-> parse_uri($xml_file);

or like so:

    my $machine = Pipeline(
         do {
             my $xslt = XML::Filter::XSLT-> new();
             $xslt-> set_stylesheet_uri("my_pdflib.xsl");
             $xslt;
           },
         "XML::Filter::PDF",
         $pdf_file,
       );
  
   
    $machine-> parse_uri($xml_file);

- Barrie
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Aaron Straup Cope
Matt Sergeant
Barrie Slaymaker

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