Event Handling

Notes:

  1. All data is always returned in UTF-8!
  2. The first argument to most handlers (expat) is the parser object.
Init(expat)
Before parsing starts
Final(expat)
After parsing has finished, if no errors
Start(expat, type, att, val, ...)
for each start-tag. Any number of attribute-value pairs
End(expat, type)
for each end-tag
Char(expat, string)
for character data. A big chunk of text, or text with entities embedded, can generate multiple calls to this handler
Proc(expat, target, data)
for each PI
Comment(expat, data)
for each comment
Default(expat, string)
for anything that doesn't have a handler
Unparsed(expat, name, base, sysID, pubID, notation)
for declaration of an unparsed entity. See expat documentation for details
Notation(expat, notation, base, sysID, pubID)
for declaration of a notation
ExternEnt(expat, base, sysID, pubID)
for reference to an external entity. Return a string or a file-handle and the external entity will be parsed.
Entity(expat, name, val, sysID, pubID, notation)
for entity declarations
Element(expat, name, model)
for element declarations
Attlist(expat, elname, attname, type, default, fixed)
for each attribute declaration. Thus, a single <!ATTLIST declaration can generate multiple calls to this handler
Doctype(expat, name, sysID, pubID, internal)
for the document type declaration. The external IDs are for the external subset, if any. internal has the full text of the internal subset, minus unparsed entity declarations, comments, and PIs that have been eaten by their respective handlers
XMLDecl(expat, version, encoding, standalone)
for the XML declaration
Title Page Road Map Where to Get These Slides Who Am I? What Is Perl? What Perl Is What Perl Feels Like Reasons to Love Perl Reasons to Fear Perl Perl's Competitors Perl Today How to Learn Perl How to Get Perl (It's Free!) Some Perl Packages Introducing CPAN Packages When To Use Perl Good Reasons to Use Perl Good Reasons to Avoid Perl The Perl/XML Software Architecture How the Pieces Fit Together  XML Processor  - Creating a Parser  - Handling Tags  - Handling Text  - PIs & Comments  - The Default Handler  - Entity Declarations  - External Entity References  - Parsing Text!  Package  Package How the Pieces Fit Together Example 1 - Count Comments Declaring Handlers Event Handling Introducing Parser Object Methods Parser Object Method List Miscellaneous Options Namespace Processing Entity Control Multiple Documents in a Stream Switching Handlers XML::Parser Styles  Style  Style  Styles  Style  Style Turn Verse Numbers to Attributes There's More Than One Way To Do It! That Irritating <p> OK, Lose the <p>'s There's More Than One Way To Do It! Find Jesus! Build a Term List from the XML Spec Perl/XML Applications  Details  Application  Snippets  Snippets Conclusions Lessons Perl and XML are mainstream technology!