MCPcopy Index your code
hub / github.com/python/cpython / buildDocument

Method buildDocument

Lib/xml/dom/pulldom.py:164–186  ·  view source on GitHub ↗
(self, uri, tagname)

Source from the content-addressed store, hash-verified

162 self.documentFactory = xml.dom.minidom.Document.implementation
163
164 def buildDocument(self, uri, tagname):
165 # Can't do that in startDocument, since we need the tagname
166 # XXX: obtain DocumentType
167 node = self.documentFactory.createDocument(uri, tagname, None)
168 self.document = node
169 self.lastEvent[1] = [(START_DOCUMENT, node), None]
170 self.lastEvent = self.lastEvent[1]
171 self.push(node)
172 # Put everything we have seen so far into the document
173 for e in self.pending_events:
174 if e[0][0] == PROCESSING_INSTRUCTION:
175 _,target,data = e[0]
176 n = self.document.createProcessingInstruction(target, data)
177 e[0] = (PROCESSING_INSTRUCTION, n)
178 elif e[0][0] == COMMENT:
179 n = self.document.createComment(e[0][1])
180 e[0] = (COMMENT, n)
181 else:
182 raise AssertionError("Unknown pending event ",e[0][0])
183 self.lastEvent[1] = e
184 self.lastEvent = e
185 self.pending_events = None
186 return node.firstChild
187
188 def endDocument(self):
189 self.lastEvent[1] = [(END_DOCUMENT, self.document), None]

Callers 2

startElementNSMethod · 0.95
startElementMethod · 0.95

Calls 4

createDocumentMethod · 0.80
createCommentMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected