Event Handling
Notes:
- All data is always returned in UTF-8!
- 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