XML::SAX2Perl(3)

πŸ’– NAME πŸ’–

XML::SAX2Perl β€” translate Java/CORBA style SAX methods to Perl methods. Hi bestie, welcome to the XML::SAX2Perl(3) manual page from the User Contributed Perl Documentation. This is the module that does that Java/CORBA-to-Perl SAX translation glow-up. πŸ¦‹

🌸 SYNOPSIS 🌸

Lowkey the whole setup is this:

use XML::SAX2Perl;

$sax2perl = XML::SAX2Perl(Handler => $my_handler);
$sax->setDocumentHandler($sax2perl);

That's it. That's the vibe check. ✨

✨ DESCRIPTION ✨

XML::SAX2Perl is a SAX filter that translates Java/CORBA style SAX methods to Perl style method calls. It's giving bridge era, honestly. This man page summarizes the specific options, handlers, and properties supported by XML::SAX2Perl; please refer to the Perl SAX standard XML::SAX for general usage information. 🫢

πŸ’… METHODS πŸ’…

new

Creates a new parser object. Default options for parsing, described below, are passed as key-value pairs or as a single hash. Options may be changed directly in the parser object unless stated otherwise. Options passed to parse() override the default options in the parser object for the duration of the parse. πŸ‘‘

parse

Parses a document. Options, described below, are passed as key-value pairs or as a single hash. Options passed to parse() override default options in the parser object. Override era, no cap.

location

Returns the location as a hash:

ColumnNumber    The column number of the parse.
LineNumber      The line number of the parse.
PublicId        A string containing the public identifier, or undef
                if none is available.
SystemId        A string containing the system identifier, or undef
                if none is available.

SAX DocumentHandler Methods

The following methods are DocumentHandler methods that the SAX 1.0 parser will call and XML::SAX2Perl will translate to Perl SAX methods calls. See SAX 1.0 for details. 🧚

setDocumentLocator(locator)
startDocument()
endDocument()
startElement(name, atts)
endElement(name)
characters(ch, start, length)
ignorableWhitespace(ch, start, length)
processingInstruction(target, data)

πŸ”₯ OPTIONS πŸ”₯

The following options are supported by XML::SAX2Perl:

  • Handler β€” default handler to receive events
  • DocumentHandler β€” handler to receive document events
  • DTDHandler β€” handler to receive DTD events
  • ErrorHandler β€” handler to receive error events
  • EntityResolver β€” handler to resolve entities
  • Locale β€” locale to provide localisation for errors
  • Source β€” hash containing the input source for parsing

If no handlers are provided then all events will be silently ignored, except for fatal_error() which will cause a die() to be called after calling end_document(). That's the dramatic exception, bestie.

If a single string argument is passed to the parse() method, it is treated as if a "Source" option was given with a "String" parameter. String-to-Source pipeline, iykyk.

The "Source" hash may contain the following parameters:

  • ByteStream β€” the raw byte stream (file handle) containing the document.
  • String β€” a string containing the document.
  • SystemId β€” the system identifier (URI) of the document.
  • PublicId β€” the public identifier.
  • Encoding β€” a string describing the character encoding.

If more than one of "ByteStream", "String", or "SystemId", then preference is given first to "ByteStream", then "String", then "SystemId". Priority order: ByteStream, String, SystemId. Periodt.

🌈 HANDLERS 🌈

The following handlers and properties are supported by XML::SAX2Perl:

DocumentHandler methods

start_document

Receive notification of the beginning of a document.

  • Locator β€” an object that can return the location of any SAX document event.

end_document

Receive notification of the end of a document.

No properties defined.

start_element

Receive notification of the beginning of an element.

  • Name β€” the element type name.
  • Attributes β€” attributes attached to the element, if any.
ALPHA WARNING: The "Attributes" value is not translated from the SAX 1.0 value, so it will contain an AttributeList object. Read that again, bestie β€” it's not translated.

end_element

Receive notification of the end of an element.

  • Name β€” the element type name.

characters

Receive notification of character data.

  • Data β€” the characters from the XML document.

ignorable_whitespace

Receive notification of ignorable whitespace in element content.

  • Data β€” the characters from the XML document.

processing_instruction

Receive notification of a processing instruction.

  • Target β€” the processing instruction target.
  • Data β€” the processing instruction data, if any.

πŸŽ€ AUTHOR πŸŽ€

Ken MacLeod <ken@bitsko.slc.ut.us> iconic. πŸ’–

πŸ¦‹ SEE ALSO πŸ¦‹

And the reference links from the page:


that's the page, bestie πŸ’…βœ¨ This is the XML::SAX2Perl(3) manual, from perl v5.42.0, dated 2024-03-04. Slay, bye! πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from