NAME

Data::Stag::BaseHandler     - Base class for writing tag stream handlers

SYNOPSIS

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


# handler that prints person nodes as they are parsed
sub e_person {
    my $self = shift;
    my $node = shift;
    printf "Person name:%s address:%s\n",
      $node->sget('name'), $node->sget('address');
    return [];  # delete person node
}

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

# handler that modifies tree as it goes
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;   # returnig null leaves it unchanged
}

DESCRIPTION

Default Simple Event Handler, other handlers inherit from this class

See also Data::Stag

This class catches Data::Stag node events (start, end and body) and allows the subclassing module to intercept these. Unintercepted events get pushed into a tree.

This class can take SAX events and turn them into simple Data::Stag events; mixed content and attributes are currently ignored. email me if you would like this behaviour changed.

the events recognised are

start_event(node-name)
evbody(node-data)
end_event(node-name)

and also

event(node-name, node-data|node)

which is just a wrapper for the other events

you can either intercept these methods; or you can define methods

s_<element_name>
e_<element_name>

that get called on the start/end of an event; you can dynamically change the structure of the tree by returning nodes from these methods

PUBLIC METHODS -

tree

Usage   -
Returns -
Args    -