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
attribute
for 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. Theconstraint
is 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,default
isNone
.elementDecl(
name, contentModel
)
This method is called by the parser when it encounters an element declaration.
name
is the name of the element type, andcontentModel
is 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( ...
Get Python & XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.