LINUX CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>

7-DAY TOP DOWNLOAD

#
Program
BackTrack 3.0 / 4.0
Pre-Final

5,182
Ubuntu 9.10
4,127
VLC 1.0.3
3,071
Wine 1.0.1 / 1.1.32
2,587
Yahoo Messenger
1.0.4

2,260
Thunderbird PST
Import plugin 1.2

2,152
Adobe Flash Player
for Linux 10.0.32.18

2,104
Mandriva Linux
2010.0

1,859
Super Grub Disk
0.9799

1,463
Yellow Dog Linux 6.2
1,299

WEEK'S BEST

  • Ubuntu 9.10
  • Ubuntu Netbook Rem...
  • Pidgin 2.6.3
  • Wine 1.0.1 / 1.1.32
  • Linux Kernel 2.6.3...
  • Mozilla Firefox 3....
  • Fedora 11
  • OpenOffice.org 3.1.1
  • Firestarter 1.0.3
  • The Gimp 2.6.7 / 2...
  • FileZilla 3.2.8.1 ...
  • Transmission 1.76
  • Super Grub Disk 0....
  • Gufw 9.04.2
  • Skype 2.0.072 / 2....
  • openSUSE Linux 11....
  • Opera 10.01 / 10.1...
  • Adobe Flash Player...
  • wine-doors 0.1.3
  • Google Gadgets 0.1...
  • Home / Linux / Programming / Perl Modules

    Data::Stag::BaseHandler 0.11

    Download button

    No screenshots available
    Downloads: 77  Add to download basket  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Chris Mungall | More programs
    Perl Artistic License / FREE
    July 11th, 2009, 00:53 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Add a review  Refer to a friend  Subscribe

     

    Data::Stag::BaseHandler description

     

    Base class for writing tag stream handlers

    Data::Stag::BaseHandler is a simple event handler, other handlers inherit from this class.

    Stag has an event-handling architecture; parsers or generators generate or fire events. Events can be hierarchical/nested, just like stag nodes. These events are caught by handlers. By default, uncaught events stack to form stag trees.

    Stag has built in parsers for parsing xml, sxpr and itext data. You can construct your own parsers for dealing with your own formats specific to your own data; these should inherit from Data::Stag::BaseGenerator

    Stag also has built in handlers for these formats. You can construct your own - either as modules that inherit from this one, or as hashes of anonymous subroutines.

    If you wish to write your own handler that writes out to another format, you may wish to inherit from Data::Stag::Writer

    SYNOPSIS

     # EXAMPLE 1
     package MyPersonHandler;
     use base qw(Data::Stag::BaseHandler);

     # handler that prints < person > nodes as they are parsed;
     # after each < person > node is intercepted, it is discarded
     # (it does not go to form the final tree)
     sub e_person {
     my $self = shift;
     my $node = shift;
     printf "Person name:%s address:%s
    ",
     $node->sget('name'), $node->sget('address');
     return; # prune this from tree
     }
     1;
     
     # EXAMPLE 2
     package MyStatsHandler;
     use base qw(Data::Stag::BaseHandler);

     # handler that modifies tree as it goes
     # changes < measurement >< unit >inch< /unit >< quantity >10< /quantity >< /measurement >
     # to < measurement >< unit >cm< /unit >< quantity >25< /quantity >< /measurement >
     sub e_measurement {
     my $self = shift;
     my $node = shift;
     if ($node->sget('unit') eq 'inch') {
     $node->set('unit', 'cm');
     $node->set('quantity', $node->get('quantity') * 2.5);
     }
     return $node; # replace < measurement > with new data in result tree
     }
     1;
     
     # Using the handlers
     my $handler = MyHandler->new;
     my $stag = Data::Stag->parse(-fh=>$fh, -handler=>$handler);

     # Using a handler from the command line:
     unix> stag-handle.pl -m MyHandler input.xml > post-processed.xml

    Requirements:

    · Perl

      


    TAGS:

    tag stream handlers | event handler | Perl module | tag | stream | handler



    HTML code for linking to this page:


    Go to top

    Windows tabGames tabDrivers tabMac tabLinux tabScripts tabMobile tabHandheld tabGadgets tabNews tab

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   ENTER NEWS SITE   |   ENGLISH BOARD   |   ROMANIAN FORUM