XML::Handler::Subs(3)
π¦ XML::Handler::Subs(3) β User Contributed Perl Documentation π¦
okay bestie, welcome to the XML::Handler::Subs page β¨ this is the User Contributed Perl Documentation vibe for a PerlSAX handler base class, and we're gonna make it make sense. no cap π
π NAME π
XML::Handler::Subs β a PerlSAX handler base class for calling user-defined subs. it's giving base-class royalty π
β¨ SYNOPSIS β¨
use XML::Handler::Subs;
package MyHandlers;
use vars qw{ @ISA };
sub s_NAME { my ($self, $element) = @_ };
sub e_NAME { my ($self, $element) = @_ };
$self->{Names}; # an array of names
$self->{Nodes}; # an array of $element nodes
$handler = MyHandlers->new();
$self->in_element($name);
$self->within_element($name);
πΈ DESCRIPTION πΈ
XML::Handler::Subs is a base class for PerlSAX handlers. you subclass it to implement complete behavior and to add element-specific handling. main character energy for handler subclasses, honestly π
Every time an element starts, a method with that name prefixed with s_ is called with the element to be processed. Every time an element ends, a method with that name prefixed with e_ is called. any special characters in the element name are replaced by underscores. slay, predictable naming β¨
Subclassing XML::Handler::Subs in this way is similar to XML::Parser's Subs style. iykyk π«Ά
XML::Handler::Subs maintains a stack of element names, "$self-"{Names}, and a stack of element nodes, "$self-"{Nodes}>, that can be used by subclasses. the current element is pushed on the stacks before calling an element-name start method and popped off the stacks after calling the element-name end method. the in_element() and within_element() calls use these stacks. bestie, the stacks are literally doing the work π
If your subclass implements start_document(), end_document(), start_element(), and end_element(), be sure to use "SUPER::" to call the superclass methods also. See perlobj(1) for details on SUPER::. SUPER::start_element() and SUPER::end_element() return 1 if an element-name method is called, and they return 0 if no method was called. that part matters, don't skip it π
XML::Handler::Subs does not implement any other PerlSAX handlers. periodt.
XML::Handler::Subs supports the following methods:
new( OPTIONS )β a basicnew()method.new()takes a list of key, value pairs or a hash and creates and returns a hash with those options; the hash is blessed into the subclass. basic but iconic πin_element($name)β returns true if$nameis equal to the name of the innermost currently opened element. fr fr.within_element($name)β returns the number of times$nameappears in Names. count 'em π
π AUTHOR π
Ken MacLeod, ken@bitsko.slc.ut.us β the icon behind this one π
π¦ SEE ALSO π¦
perl(1), PerlSAX.pod(3) β go read those too, bestie π
mwah π β this page is from perl v5.42.0, dated 2024-03-04, and it's the XML::Handler::Subs(3) page. bye bestie, go slay some PerlSAX handlers πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-libxml-perl 0.08-160000.2.2 Β· Artistic-1.0 OR GPL-2.0-or-later
- opensuse-leap 16.0: perl-libxml-perl 0.08-160000.2.2 Β· Artistic-1.0 OR GPL-2.0-or-later
- opensuse-leap 16.0: perl-libxml-perl 0.08-160000.2.2 Β· Artistic-1.0 OR GPL-2.0-or-later
- opensuse-leap 16.0: perl-libxml-perl 0.08-160000.2.2 Β· Artistic-1.0 OR GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms