XML::SA...tLocator(3)
πΈ NAME πΈ
XML::SAX::DocumentLocator β bestie's fave little helper class for document locators, no cap π
β¨ SYNOPSIS β¨
okay so here's the whole vibe, literally copy-paste blessed:
my $locator = XML::SAX::DocumentLocator->new(
sub { $object->get_public_id },
sub { $object->get_system_id },
sub { $reader->current_line },
sub { $reader->current_column },
sub { $reader->get_encoding },
sub { $reader->get_xml_version },
);
likeβ¦ look at her go π
π¦ DESCRIPTION π¦
so this module hands you a tied hash reference that calls the closures you specify whenever someone asks it for PublicId, SystemId, LineNumber and ColumnNumber. the way that it just knows?? iconic. π₯
it's highkey useful when you're writing SAX Parsers, because then you don't have to constantly update the line numbers in a hash reference on the object you pass to set_document_locator(). that's the whole point, fr fr β no more manual bookkeeping era π
want a usage example? go peek at the source code for XML::SAX::PurePerl, it's right there being a whole role model π
π API π
there is literally only 1 method: new. that's it. that's the API. slay π
simply pass it a list of closures that, when called, will return the PublicId, the SystemId, the LineNumber, the ColumnNumber, the Encoding and the XMLVersion respectively β in that exact order, bestie, order matters π
the closures are passed a single parameter: the key being requested. but honestly? you're free to ignore that. do what feels right β¨
and that's the whole page, bestie β go forth and locate those documents π«Ά
this gem was brought to you by perl v5.42.0, dated 2024-03-04 β mwah, ily, bye π
π¦ where this page comes from
- opensuse-leap 16.0: perl-XML-SAX 1.02-160000.2.2 Β· GPL-1.0-or-later OR Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms