Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
xml.dom.expatbuilder.InternalSubsetExtractor Class Reference
Inheritance diagram for xml.dom.expatbuilder.InternalSubsetExtractor:
Inheritance graph
[legend]
Collaboration diagram for xml.dom.expatbuilder.InternalSubsetExtractor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def getSubset
def parseFile
def parseString
def install
def start_doctype_decl_handler
def end_doctype_decl_handler
def start_element_handler
def createParser
def getParser
def reset
def pi_handler
def character_data_handler_cdata
def character_data_handler
def entity_decl_handler
def notation_decl_handler
def comment_handler
def start_cdata_section_handler
def end_cdata_section_handler
def external_entity_ref_handler
def first_element_handler
def end_element_handler
def element_decl_handler
def attlist_decl_handler
def xml_decl_handler

Public Attributes

 document
 curNode

Static Public Attributes

 subset = None

Detailed Description

XML processor which can rip out the internal document type subset.

Definition at line 867 of file expatbuilder.py.


Member Function Documentation

def xml.dom.expatbuilder.ExpatBuilder.attlist_decl_handler (   self,
  elem,
  name,
  type,
  default,
  required 
) [inherited]

Definition at line 440 of file expatbuilder.py.

00440 
00441     def attlist_decl_handler(self, elem, name, type, default, required):
00442         info = self._elem_info.get(elem)
00443         if info is None:
00444             info = ElementInfo(elem)
00445             self._elem_info[elem] = info
00446         info._attr_info.append(
00447             [None, name, None, None, default, 0, type, required])

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.character_data_handler (   self,
  data 
) [inherited]

Definition at line 296 of file expatbuilder.py.

00296 
00297     def character_data_handler(self, data):
00298         childNodes = self.curNode.childNodes
00299         if childNodes and childNodes[-1].nodeType == TEXT_NODE:
00300             node = childNodes[-1]
00301             d = node.__dict__
00302             d['data'] = d['nodeValue'] = node.data + data
00303             return
00304         node = minidom.Text()
00305         d = node.__dict__
00306         d['data'] = d['nodeValue'] = node.data + data
00307         d['ownerDocument'] = self.document
00308         _append_child(self.curNode, node)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 274 of file expatbuilder.py.

00274 
00275     def character_data_handler_cdata(self, data):
00276         childNodes = self.curNode.childNodes
00277         if self._cdata:
00278             if (  self._cdata_continue
00279                   and childNodes[-1].nodeType == CDATA_SECTION_NODE):
00280                 childNodes[-1].appendData(data)
00281                 return
00282             node = self.document.createCDATASection(data)
00283             self._cdata_continue = True
00284         elif childNodes and childNodes[-1].nodeType == TEXT_NODE:
00285             node = childNodes[-1]
00286             value = node.data + data
00287             d = node.__dict__
00288             d['data'] = d['nodeValue'] = value
00289             return
00290         else:
00291             node = minidom.Text()
00292             d = node.__dict__
00293             d['data'] = d['nodeValue'] = data
00294             d['ownerDocument'] = self.document
00295         _append_child(self.curNode, node)

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.comment_handler (   self,
  data 
) [inherited]

Definition at line 333 of file expatbuilder.py.

00333 
00334     def comment_handler(self, data):
00335         node = self.document.createComment(data)
00336         _append_child(self.curNode, node)
00337         if self._filter and self._filter.acceptNode(node) == FILTER_REJECT:
00338             self.curNode.removeChild(node)

Here is the call graph for this function:

Here is the caller graph for this function:

Create a new parser object.

Definition at line 151 of file expatbuilder.py.

00151 
00152     def createParser(self):
00153         """Create a new parser object."""
00154         return expat.ParserCreate()

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.element_decl_handler (   self,
  name,
  model 
) [inherited]

Definition at line 432 of file expatbuilder.py.

00432 
00433     def element_decl_handler(self, name, model):
00434         info = self._elem_info.get(name)
00435         if info is None:
00436             self._elem_info[name] = ElementInfo(name, model)
00437         else:
00438             assert info._model is None
00439             info._model = model

Here is the caller graph for this function:

Definition at line 343 of file expatbuilder.py.

00343 
00344     def end_cdata_section_handler(self):
00345         self._cdata = False
00346         self._cdata_continue = False

Here is the caller graph for this function:

Reimplemented from xml.dom.expatbuilder.ExpatBuilder.

Definition at line 902 of file expatbuilder.py.

00902 
00903     def end_doctype_decl_handler(self):
00904         s = ''.join(self.subset).replace('\r\n', '\n').replace('\r', '\n')
00905         self.subset = s
00906         raise ParseEscape()

Here is the call graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.end_element_handler (   self,
  name 
) [inherited]

Definition at line 399 of file expatbuilder.py.

00399 
00400     def end_element_handler(self, name):
00401         curNode = self.curNode
00402         self.curNode = curNode.parentNode
00403         self._finish_end_element(curNode)

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.entity_decl_handler (   self,
  entityName,
  is_parameter_entity,
  value,
  base,
  systemId,
  publicId,
  notationName 
) [inherited]

Definition at line 310 of file expatbuilder.py.

00310 
00311                             base, systemId, publicId, notationName):
00312         if is_parameter_entity:
00313             # we don't care about parameter entities for the DOM
00314             return
00315         if not self._options.entities:
00316             return
00317         node = self.document._create_entity(entityName, publicId,
00318                                             systemId, notationName)
00319         if value is not None:
00320             # internal entity
00321             # node *should* be readonly, but we'll cheat
00322             child = self.document.createTextNode(value)
00323             node.childNodes.append(child)
00324         self.document.doctype.entities._seq.append(node)
00325         if self._filter and self._filter.acceptNode(node) == FILTER_REJECT:
00326             del self.document.doctype.entities._seq[-1]

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.external_entity_ref_handler (   self,
  context,
  base,
  systemId,
  publicId 
) [inherited]

Definition at line 347 of file expatbuilder.py.

00347 
00348     def external_entity_ref_handler(self, context, base, systemId, publicId):
00349         return 1

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.first_element_handler (   self,
  name,
  attributes 
) [inherited]

Definition at line 350 of file expatbuilder.py.

00350 
00351     def first_element_handler(self, name, attributes):
00352         if self._filter is None and not self._elem_info:
00353             self._finish_end_element = id
00354         self.getParser().StartElementHandler = self.start_element_handler
00355         self.start_element_handler(name, attributes)

Here is the call graph for this function:

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.getParser (   self) [inherited]
Return the parser object, creating a new one if needed.

Definition at line 155 of file expatbuilder.py.

00155 
00156     def getParser(self):
00157         """Return the parser object, creating a new one if needed."""
00158         if not self._parser:
00159             self._parser = self.createParser()
00160             self._intern_setdefault = self._parser.intern.setdefault
00161             self._parser.buffer_text = True
00162             self._parser.ordered_attributes = True
00163             self._parser.specified_attributes = True
00164             self.install(self._parser)
00165         return self._parser

Here is the call graph for this function:

Here is the caller graph for this function:

Return the internal subset as a string.

Definition at line 872 of file expatbuilder.py.

00872 
00873     def getSubset(self):
00874         """Return the internal subset as a string."""
00875         return self.subset

Install the callbacks needed to build the DOM into the parser.

Reimplemented from xml.dom.expatbuilder.ExpatBuilder.

Definition at line 888 of file expatbuilder.py.

00888 
00889     def install(self, parser):
00890         parser.StartDoctypeDeclHandler = self.start_doctype_decl_handler
00891         parser.StartElementHandler = self.start_element_handler

Here is the call graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.notation_decl_handler (   self,
  notationName,
  base,
  systemId,
  publicId 
) [inherited]

Definition at line 327 of file expatbuilder.py.

00327 
00328     def notation_decl_handler(self, notationName, base, systemId, publicId):
00329         node = self.document._create_notation(notationName, publicId, systemId)
00330         self.document.doctype.notations._seq.append(node)
00331         if self._filter and self._filter.acceptNode(node) == FILTER_ACCEPT:
00332             del self.document.doctype.notations._seq[-1]

Here is the caller graph for this function:

Parse a document from a file object, returning the document
node.

Reimplemented from xml.dom.expatbuilder.ExpatBuilder.

Definition at line 876 of file expatbuilder.py.

00876 
00877     def parseFile(self, file):
00878         try:
00879             ExpatBuilder.parseFile(self, file)
00880         except ParseEscape:
00881             pass

Parse a document from a string, returning the document node.

Reimplemented from xml.dom.expatbuilder.ExpatBuilder.

Definition at line 882 of file expatbuilder.py.

00882 
00883     def parseString(self, string):
00884         try:
00885             ExpatBuilder.parseString(self, string)
00886         except ParseEscape:
00887             pass

def xml.dom.expatbuilder.ExpatBuilder.pi_handler (   self,
  target,
  data 
) [inherited]

Definition at line 268 of file expatbuilder.py.

00268 
00269     def pi_handler(self, target, data):
00270         node = self.document.createProcessingInstruction(target, data)
00271         _append_child(self.curNode, node)
00272         if self._filter and self._filter.acceptNode(node) == FILTER_REJECT:
00273             self.curNode.removeChild(node)

Here is the call graph for this function:

Here is the caller graph for this function:

def xml.dom.expatbuilder.ExpatBuilder.reset (   self) [inherited]
Free all data structures used during DOM construction.

Reimplemented in xml.dom.expatbuilder.FragmentBuilderNS, xml.dom.expatbuilder.ExpatBuilderNS, and xml.dom.expatbuilder.FragmentBuilder.

Definition at line 166 of file expatbuilder.py.

00166 
00167     def reset(self):
00168         """Free all data structures used during DOM construction."""
00169         self.document = theDOMImplementation.createDocument(
00170             EMPTY_NAMESPACE, None, None)
00171         self.curNode = self.document
00172         self._elem_info = self.document._elem_info
00173         self._cdata = False

Here is the caller graph for this function:

Definition at line 339 of file expatbuilder.py.

00339 
00340     def start_cdata_section_handler(self):
00341         self._cdata = True
00342         self._cdata_continue = False

Here is the caller graph for this function:

def xml.dom.expatbuilder.InternalSubsetExtractor.start_doctype_decl_handler (   self,
  name,
  publicId,
  systemId,
  has_internal_subset 
)

Reimplemented from xml.dom.expatbuilder.ExpatBuilder.

Definition at line 893 of file expatbuilder.py.

00893 
00894                                    has_internal_subset):
00895         if has_internal_subset:
00896             parser = self.getParser()
00897             self.subset = []
00898             parser.DefaultHandler = self.subset.append
00899             parser.EndDoctypeDeclHandler = self.end_doctype_decl_handler
00900         else:
00901             raise ParseEscape()

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from xml.dom.expatbuilder.ExpatBuilder.

Definition at line 907 of file expatbuilder.py.

00907 
00908     def start_element_handler(self, name, attrs):
00909         raise ParseEscape()
00910 

def xml.dom.expatbuilder.ExpatBuilder.xml_decl_handler (   self,
  version,
  encoding,
  standalone 
) [inherited]

Definition at line 448 of file expatbuilder.py.

00448 
00449     def xml_decl_handler(self, version, encoding, standalone):
00450         self.document.version = version
00451         self.document.encoding = encoding
00452         # This is still a little ugly, thanks to the pyexpat API. ;-(
00453         if standalone >= 0:
00454             if standalone:
00455                 self.document.standalone = True
00456             else:
00457                 self.document.standalone = False
00458 
00459 
00460 # Don't include FILTER_INTERRUPT, since that's checked separately
# where allowed.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 170 of file expatbuilder.py.

Definition at line 168 of file expatbuilder.py.

Definition at line 870 of file expatbuilder.py.


The documentation for this class was generated from the following file: