xml.dom.expatbuilder
index
/usr/local/lib/python2.3/xml/dom/expatbuilder.py

Facility to use the Expat parser to load a minidom instance
from a string or file.
 
This avoids all the overhead of SAX and pulldom to gain performance.

 
Modules
       
xml.parsers.expat
xml.dom.minidom
xml.dom.xmlbuilder

 
Classes
       
exceptions.Exception
ParseEscape
ExpatBuilder
FragmentBuilder
InternalSubsetExtractor
Namespaces
ExpatBuilderNS(Namespaces, ExpatBuilder)
FragmentBuilderNS(Namespaces, FragmentBuilder)
__builtin__.object
ElementInfo
FilterCrutch
Rejecter
Skipper
FilterVisibilityController

 
class ElementInfo(__builtin__.object)
     Methods defined here:
__getstate__(self)
__init__(self, tagName, model=None)
__setstate__(self, state)
getAttributeType(self, aname)
getAttributeTypeNS(self, namespaceURI, localName)
isElementContent(self)
isEmpty(self)
isId(self, aname)
isIdNS(self, euri, ename, auri, aname)

Data and other attributes defined here:
__slots__ = ('_attr_info', '_model', 'tagName')
tagName = <member 'tagName' of 'ElementInfo' objects>

 
class ExpatBuilder
    Document builder that uses Expat to build a ParsedXML.DOM document
instance.
 
  Methods defined here:
__init__(self, options=None)
attlist_decl_handler(self, elem, name, type, default, required)
character_data_handler(self, data)
character_data_handler_cdata(self, data)
comment_handler(self, data)
createParser(self)
Create a new parser object.
element_decl_handler(self, name, model)
end_cdata_section_handler(self)
end_doctype_decl_handler(self)
end_element_handler(self, name)
# If this ever changes, Namespaces.end_element_handler() needs to
# be changed to match.
entity_decl_handler(self, entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
external_entity_ref_handler(self, context, base, systemId, publicId)
first_element_handler(self, name, attributes)
getParser(self)
Return the parser object, creating a new one if needed.
install(self, parser)
Install the callbacks needed to build the DOM into the parser.
notation_decl_handler(self, notationName, base, systemId, publicId)
parseFile(self, file)
Parse a document from a file object, returning the document
node.
parseString(self, string)
Parse a document from a string, returning the document node.
pi_handler(self, target, data)
reset(self)
Free all data structures used during DOM construction.
start_cdata_section_handler(self)
start_doctype_decl_handler(self, doctypeName, systemId, publicId, has_internal_subset)
start_element_handler(self, name, attributes)
xml_decl_handler(self, version, encoding, standalone)

 
class ExpatBuilderNS(Namespaces, ExpatBuilder)
    Document builder that supports namespaces.
 
 
Method resolution order:
ExpatBuilderNS
Namespaces
ExpatBuilder

Methods defined here:
reset(self)

Methods inherited from Namespaces:
createParser(self)
Create a new namespace-handling parser.
end_element_handler(self, name)
# This only adds some asserts to the original
end_element_handler(), so we only define this when -O is not
# used.  If changing one, be sure to check the other to see if
# it needs to be changed as well.
install(self, parser)
Insert the namespace-handlers onto the parser.
start_element_handler(self, name, attributes)
start_namespace_decl_handler(self, prefix, uri)
Push this namespace declaration on our storage.

Methods inherited from ExpatBuilder:
__init__(self, options=None)
attlist_decl_handler(self, elem, name, type, default, required)
character_data_handler(self, data)
character_data_handler_cdata(self, data)
comment_handler(self, data)
element_decl_handler(self, name, model)
end_cdata_section_handler(self)
end_doctype_decl_handler(self)
entity_decl_handler(self, entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
external_entity_ref_handler(self, context, base, systemId, publicId)
first_element_handler(self, name, attributes)
getParser(self)
Return the parser object, creating a new one if needed.
notation_decl_handler(self, notationName, base, systemId, publicId)
parseFile(self, file)
Parse a document from a file object, returning the document
node.
parseString(self, string)
Parse a document from a string, returning the document node.
pi_handler(self, target, data)
start_cdata_section_handler(self)
start_doctype_decl_handler(self, doctypeName, systemId, publicId, has_internal_subset)
xml_decl_handler(self, version, encoding, standalone)

 
class FilterCrutch(__builtin__.object)
     Methods defined here:
__init__(self, builder)

Data and other attributes defined here:
__slots__ = ('_builder', '_level', '_old_start', '_old_end')

 
class FilterVisibilityController(__builtin__.object)
    Wrapper around a DOMBuilderFilter which implements the checks
to make the whatToShow filter attribute work.
 
  Methods defined here:
__init__(self, filter)
acceptNode(self, node)
startContainer(self, node)

Data and other attributes defined here:
__slots__ = ('filter',)
filter = <member 'filter' of 'FilterVisibilityController' objects>

 
class FragmentBuilder(ExpatBuilder)
    Builder which constructs document fragments given XML source
text and a context node.
 
The context node is expected to provide information about the
namespace declarations which are in scope at the start of the
fragment.
 
  Methods defined here:
__init__(self, context, options=None)
external_entity_ref_handler(self, context, base, systemId, publicId)
parseFile(self, file)
Parse a document fragment from a file object, returning the
fragment node.
parseString(self, string)
Parse a document fragment from a string, returning the
fragment node.
reset(self)

Methods inherited from ExpatBuilder:
attlist_decl_handler(self, elem, name, type, default, required)
character_data_handler(self, data)
character_data_handler_cdata(self, data)
comment_handler(self, data)
createParser(self)
Create a new parser object.
element_decl_handler(self, name, model)
end_cdata_section_handler(self)
end_doctype_decl_handler(self)
end_element_handler(self, name)
# If this ever changes, Namespaces.end_element_handler() needs to
# be changed to match.
entity_decl_handler(self, entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
first_element_handler(self, name, attributes)
getParser(self)
Return the parser object, creating a new one if needed.
install(self, parser)
Install the callbacks needed to build the DOM into the parser.
notation_decl_handler(self, notationName, base, systemId, publicId)
pi_handler(self, target, data)
start_cdata_section_handler(self)
start_doctype_decl_handler(self, doctypeName, systemId, publicId, has_internal_subset)
start_element_handler(self, name, attributes)
xml_decl_handler(self, version, encoding, standalone)

 
class FragmentBuilderNS(Namespaces, FragmentBuilder)
    Fragment builder that supports namespaces.
 
 
Method resolution order:
FragmentBuilderNS
Namespaces
FragmentBuilder
ExpatBuilder

Methods defined here:
reset(self)

Methods inherited from Namespaces:
createParser(self)
Create a new namespace-handling parser.
end_element_handler(self, name)
# This only adds some asserts to the original
end_element_handler(), so we only define this when -O is not
# used.  If changing one, be sure to check the other to see if
# it needs to be changed as well.
install(self, parser)
Insert the namespace-handlers onto the parser.
start_element_handler(self, name, attributes)
start_namespace_decl_handler(self, prefix, uri)
Push this namespace declaration on our storage.

Methods inherited from FragmentBuilder:
__init__(self, context, options=None)
external_entity_ref_handler(self, context, base, systemId, publicId)
parseFile(self, file)
Parse a document fragment from a file object, returning the
fragment node.
parseString(self, string)
Parse a document fragment from a string, returning the
fragment node.

Methods inherited from ExpatBuilder:
attlist_decl_handler(self, elem, name, type, default, required)
character_data_handler(self, data)
character_data_handler_cdata(self, data)
comment_handler(self, data)
element_decl_handler(self, name, model)
end_cdata_section_handler(self)
end_doctype_decl_handler(self)
entity_decl_handler(self, entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
first_element_handler(self, name, attributes)
getParser(self)
Return the parser object, creating a new one if needed.
notation_decl_handler(self, notationName, base, systemId, publicId)
pi_handler(self, target, data)
start_cdata_section_handler(self)
start_doctype_decl_handler(self, doctypeName, systemId, publicId, has_internal_subset)
xml_decl_handler(self, version, encoding, standalone)

 
class InternalSubsetExtractor(ExpatBuilder)
    XML processor which can rip out the internal document type subset.
 
  Methods defined here:
end_doctype_decl_handler(self)
getSubset(self)
Return the internal subset as a string.
install(self, parser)
parseFile(self, file)
parseString(self, string)
start_doctype_decl_handler(self, name, publicId, systemId, has_internal_subset)
start_element_handler(self, name, attrs)

Data and other attributes defined here:
subset = None

Methods inherited from ExpatBuilder:
__init__(self, options=None)
attlist_decl_handler(self, elem, name, type, default, required)
character_data_handler(self, data)
character_data_handler_cdata(self, data)
comment_handler(self, data)
createParser(self)
Create a new parser object.
element_decl_handler(self, name, model)
end_cdata_section_handler(self)
end_element_handler(self, name)
# If this ever changes, Namespaces.end_element_handler() needs to
# be changed to match.
entity_decl_handler(self, entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
external_entity_ref_handler(self, context, base, systemId, publicId)
first_element_handler(self, name, attributes)
getParser(self)
Return the parser object, creating a new one if needed.
notation_decl_handler(self, notationName, base, systemId, publicId)
pi_handler(self, target, data)
reset(self)
Free all data structures used during DOM construction.
start_cdata_section_handler(self)
xml_decl_handler(self, version, encoding, standalone)

 
class Namespaces
    Mix-in class for builders; adds support for namespaces.
 
  Methods defined here:
createParser(self)
Create a new namespace-handling parser.
end_element_handler(self, name)
# This only adds some asserts to the original
end_element_handler(), so we only define this when -O is not
# used.  If changing one, be sure to check the other to see if
# it needs to be changed as well.
install(self, parser)
Insert the namespace-handlers onto the parser.
start_element_handler(self, name, attributes)
start_namespace_decl_handler(self, prefix, uri)
Push this namespace declaration on our storage.

 
class ParseEscape(exceptions.Exception)
    Exception raised to short-circuit parsing in InternalSubsetExtractor.
 
  Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class Rejecter(FilterCrutch)
    
Method resolution order:
Rejecter
FilterCrutch
__builtin__.object

Methods defined here:
__init__(self, builder)
end_element_handler(self, *args)
start_element_handler(self, *args)

Data and other attributes defined here:
__slots__ = ()

 
class Skipper(FilterCrutch)
    
Method resolution order:
Skipper
FilterCrutch
__builtin__.object

Methods defined here:
end_element_handler(self, *args)
start_element_handler(self, *args)

Data and other attributes defined here:
__slots__ = ()

Methods inherited from FilterCrutch:
__init__(self, builder)

 
Functions
       
makeBuilder(options)
Create a builder based on an Options object.
parse(file, namespaces=1)
Parse a document, returning the resulting Document node.
 
'file' may be either a file name or an open file object.
parseFragment(file, context, namespaces=1)
Parse a fragment of a document, given the context from which it
was originally extracted.  context should be the parent of the
node(s) which are in the fragment.
 
'file' may be either a file name or an open file object.
parseFragmentString(string, context, namespaces=1)
Parse a fragment of a document from a string, given the context
from which it was originally extracted.  context should be the
parent of the node(s) which are in the fragment.
parseString(string, namespaces=1)
Parse a document from a string, returning the resulting
Document node.

 
Data
        CDATA_SECTION_NODE = 4
DOCUMENT_NODE = 9
EMPTY_NAMESPACE = None
EMPTY_PREFIX = None
FILTER_ACCEPT = 1
FILTER_INTERRUPT = 4
FILTER_REJECT = 2
FILTER_SKIP = 3
StringTypes = (<type 'str'>, <type 'unicode'>)
TEXT_NODE = 3
XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
theDOMImplementation = <xml.dom.minidom.DOMImplementation instance>