Name
DeclHandler
Synopsis
The DeclHandler is
used to receive information about the allowed structure of a document
based on the DTD. It is supported only using PyXML; the standard
library does not support it. A simple base class for this handler is
available as the DeclHandler class
in the xml.sax.saxlib module. The
DeclHandler can be set using the
setProperty method on the parser
object, using the property constant property_declaration_handler from the
xml.sax.handler module.
attributeDecl(element, attribute, type, constraint, default)The parser calls this method for each attribute declared. The call represents the declaration of the attribute named
attributefor the element typeelement. The data type of the attribute, given astype, is provided as a string with a value ofCDATA,ENTITY,ENTITIES,ID,IDREF,IDREFS,NMTOKEN,NMTOKENS, orNOTATION, or as a list of strings for enumerated types. Theconstraintis given as a string orNone, with the possible string values#FIXED,#IMPLIED, and#REQUIRED. If the attribute has a default value, it is provided asdefault; if no default is defined,defaultisNone.elementDecl(name, contentModel)This method is called by the parser when it encounters an element declaration.
nameis the name of the element type, andcontentModelis its content model. The content module is the stringEMPTY, the stringANY, or a tuple containing the model separator character, the list of element type names, and the quantity modifier.externalEntityDecl( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access