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 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( ...

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.