示例#1
0
 def testOwnerDocument(self):
     doc = Document()
     node = doc.createElement('node')
     one = doc.createElement('one')
     two = doc.createTextNode('two')
     three = doc.createElement('three')
     node.append(one)
     node.append(two)
     node.attributes['three'] = three
     a = Text('a')
     b = Text('b')
     node.attributes['four'] = {'a': a, 'b': 1}
     node.attributes['five'] = [b, 1, 'c']
     assert node.ownerDocument is doc, '"%s" != "%s"' % (node.ownerDocument,
                                                         doc)
     assert one.ownerDocument is doc, '"%s" != "%s"' % (one.ownerDocument,
                                                        doc)
     assert two.ownerDocument is doc, '"%s" != "%s"' % (two.ownerDocument,
                                                        doc)
     assert three.ownerDocument is doc, '"%s" != "%s"' % (
         three.ownerDocument, doc)
     assert a.ownerDocument is doc, '"%s" != "%s"' % (a.ownerDocument, doc)
     assert b.ownerDocument is doc, '"%s" != "%s"' % (b.ownerDocument, doc)
     self._checkPositions(node)
示例#2
0
 def textContent(self):
     """
     We need a customized textContent that doesn't look up 
     textContent recursively.
     
     """
     output = []
     for item in self:
         if item.nodeType == Node.TEXT_NODE:
             output.append(item)
         elif getattr(item, 'unicode', None) is not None:
             output.append(item.unicode)
         else:
             output.append(item.textContent)
     if self.ownerDocument is not None:
         return self.ownerDocument.createTextNode(u''.join(output))
     else:
         return Text(u''.join(output))        
示例#3
0
 def digest(self, tokens):
     verb.digest(self, tokens)
     self.str = Text(''.join(self))
     self.str.isMarkup = True
     return []
示例#4
0
 def digest(self, tokens):
     verbatim.digest(self, tokens)
     self.unicode = Text(''.join(self))
     self.unicode.isMarkup = True
     return []