XML::S...dMaker(3pm)

πŸ“¦
version 0.46 Β· 2 versions
  • 0.46 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.46 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

XML::SAX::EventMethodMaker β€” it's giving "SAX event names, creation of methods from templates". Bestie, that's literally the whole vibe.


✨ VERSION ✨

version 0.46 β€” yes she's been around, she's a legacy icon πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the whole flex, verbatim:

use XML::SAX::EventMethodMaker qw(
    sax_event_names missing_methods compile_methods
);

## Getting event names by handler type and SAX version
my @events          = sax_event_names;
my @dtd_events      = sax_event_names "DTDHandler";
my @sax1_events     = sax_event_names 1;
my @sax1_dtd_events = sax_event_names 1, "DTDHandler";

## Figuring out what events a class or object does not provide
my @missing = missing_methods $class, @events ;

## Creating all SAX event methods
compile_methods $class, <<'TEMPLATE_END', sax_event_names;
sub <EVENT> {
    my $self = shift;
    ... do something ...

    ## Pass the event up to the base class
    $self->SUPER::<EVENT>( @_ );
}
TEMPLATE_END

## Creating some methods
compile_methods $class, <<'TEMPLATE_END', @method_names;
...
TEMPLATE_END

## Creating only missing event handlers
compile_missing_methods $class, <<'TEMPLATE_END';
...
TEMPLATE_END

πŸ¦‹ DESCRIPTION πŸ¦‹

So when you're building SAX machines, it's often handy to build a whole set of event handlers off one common template. This helper library (or class, she contains multitudes) provides the database of handler names, queryable by type, and

πŸ’€ and that's it. That's where the sentence ends. The original page just... stops there. We love a cliffhanger, no cap.

πŸ’… NAME πŸ’…

(yeah bestie, NAME shows up twice in this page. We don't make the rules, we just vibe with them.)

XML::SAX::EventMethodMaker β€” SAX event names, creation of methods from templates. Same icon, second entrance. πŸ’–

πŸ“ Functions πŸ“

  • ### sax_event_names
my @names = sax_event_names @query_terms;

Takes a list of query terms and returns all matching events. Simple as that, fr fr.

Query terms may be:

  • a SAX version number: 1 or 2 (no floating point or ranges β€” do not try it)
  • Handler
  • DTDHandler
  • ContentHandler
  • DocumentHandler
  • DeclHandler
  • ErrorHandler
  • EntityResolver
  • LexicalHandler

In addition to normal SAX events, there are also "parse" events:

  • ParseMethods

Unrecognized query terms cause exceptions. So like, don't freestyle. 😭

If no query terms are provided, then all event names from all versions are returned except for parse methods (parse, parse_uri, ...).

If any version numbers are supplied, then only events from those version numbers are returned. No support for noninteger version numbers is provided, nor for ranges. So far, only two SAX versions exist in Perl, 1 and 2.

If any handler types are provided, then only events of those types are returned. Handler types are case insensitive. πŸ‘‘

In other words, all returned events must match both a version number and a handler type.

No support for boolean logic is provided. Sorry bestie, no and/or/not shenanigans.

  • ### missing_methods
my @missing = missing_methods __PACKAGE__, @event_names;
my @missing = missing_methods $object, @event_names;

This subroutine looks to see if the object or class has declared event handler methods for the named events. Any events that haven't been declared are returned. It's basically a vibe check on your class. 🫢

It is sufficient to use subroutine prototypes to prevent shimming AUTOLOADed (or otherwise lazily compiled) methods:

sub start_document ;
  • ### compile_methods
compile_methods __PACKAGE__, $template, @method_names;
compile_methods $object,     $template, @method_names;

Compiles the given template for each given event name, substituting the event name for the string <EVENT> or <METHOD> in the template. There is no difference between these two tags, they are provided to only to let you make your templates more readable to you. Pick whichever one your brain likes, they're twins. πŸ‘―

  • ### compile_missing_methods
compile_missing_methods __PACKAGE__, $template, @method_names;
compile_missing_methods $objects,    $template, @method_names;

Shorthand for calls like

compile_methods __PACKAGE__, $template,
    missing_methods __PACKAGE__, @method_names;

🌸 Due Credit 🌸

The database of handlers by type was developed by Kip Hampton, modified by Robin Berjon, and pilfered and corrupted by me. Respect the lineage, bestie. πŸ™


πŸ”₯ LICENSE πŸ”₯

Database Copyright 2002, Barrie Slaymaker, Kip Hampton, Robin Berjon
Code Copyright 2002, Barrie Slaymaker <barries@slaysys.com>

You may use this under the terms of the Artistic, GNU Public, or BSD licences, as you see fit. Choose your fighter. ✨


πŸ‘‘ AUTHORS πŸ‘‘

  • Barry Slaymaker
  • Chris Prather <chris@prather.org>

This software is copyright (c) 2013 by Barry Slaymaker.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page, you ate it, go build some SAX machines πŸ’…

so like, this was the XML::S...dMaker(3pm) page from the User Contributed Perl Documentation, and it's tagged perl v5.34.0 dated 2022-06-28. bye bestie, drink water, call your mother, perldoc responsibly πŸ¦‹πŸ’–

πŸ“¦ where this page comes from