DeclHandler
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 type
element
. The data type of the
attribute, given as type
, is provided
as a string with a value of CDATA
, ENTITY
, ENTITIES
, ID
, IDREF
, IDREFS
, NMTOKEN
, NMTOKENS
, or NOTATION
, or as a list of strings for
enumerated types. The constraint
is
given as a string or None
,
with the possible string values #FIXED
, #IMPLIED
, and #REQUIRED
. If the attribute has a
default value, it is provided as
default
; if no default is defined,
default
is None
.
elementDecl(
name, contentModel
)
This method is called by the parser when it
encounters an element declaration.
name
is the name of the element type,
and contentModel
is its content
model. The content module is the string EMPTY
, the string ANY
, or a tuple containing the model
separator character, the list of element type names, and the
quantity modifier.
externalEntityDecl(
name, publicId, systemId
)
When the parsers see the definition of an external
parsed entity, it calls this method to inform the application.
The name
is the name assigned to the
entity, publicId
is the public
identifier or None
, and
systemId
is the system
identifier.
internalEntityDecl(
name, value
)
The parser calls this method when an internal
general entity is defined. The name
is the name assigned to the entity and
value
is a string giving the
replacement text for the entity.