Example #1
0
 def _4dom_raiseIfAncestor(self, node):
     "Helper function that raises if node is an ancestor of self or self."
     n = self
     if n is node:
         raise HierarchyRequestErr()
     if node.hasChildNodes():
         while n is not None:
             n = n.parentNode
             if n is node:
                 raise HierarchyRequestErr()
Example #2
0
 def appendChild(self, node):
     if hasattr(node, 'allowNoSvgChildNode'):
         if not self.allowAllSvgNodesAsChildNodes:
             if not (node.svgNodeType in self._allowedSvgChildNodes):
                 raise HierarchyRequestErr("%s cannot be child of %s" %
                                           (repr(node), repr(self)))
             else:
                 Element.appendChild(self, node)
     Element.appendChild(self, node)
Example #3
0
 def _4dom_addSingle(self, node):
     '''Make sure only one Element node is added to a Document'''
     if node.nodeType == Node.ELEMENT_NODE:
         self._4dom_validateNode(node)
         if node.parentNode != None:
             node.parentNode.removeChild(node)
         if self.__dict__['__documentElement']:
             raise HierarchyRequestErr()
         self.__dict__['__documentElement'] = node
         if self.__dict__['__doctype']:
             self.__dict__['__doctype']._4dom_setName(node.nodeName)
Example #4
0
 def replaceChild(self, newChild, oldChild):
     if newChild.nodeType != Node.DOCUMENT_FRAGMENT_NODE:
         root = self.__dict__['__documentElement']
         if root in [oldChild, newChild]:
             self.__dict__['__documentElement'] = None
         else:
             raise HierarchyRequestErr()
     replaced = FtNode.replaceChild(self, newChild, oldChild)
     if newChild.nodeType == Node.ELEMENT_NODE:
         self.__dict__['__documentElement'] = newChild
         if self.__dict__['__doctype']:
             self.__dict__['__doctype']._4dom_setName(newChild.nodeName)
     return replaced
Example #5
0
 def appendChild(self, node):
     raise HierarchyRequestErr("%s does not support child node operations" %
                               (repr(self)))
Example #6
0
 def replaceChild(self, newChild, oldChild):
     raise HierarchyRequestErr("%s does not support child node operations" %
                               (repr(self)))
Example #7
0
 def appendChild(self, newChild):
     raise HierarchyRequestErr(self.nodeName + " nodes cannot have children")
Example #8
0
 def removeChild(self, oldChild):
     raise HierarchyRequestErr(self.nodeName + " nodes cannot have children")
Example #9
0
 def insertBefore(self, newChild, refChild):
     raise HierarchyRequestErr(self.nodeName + " nodes cannot have children")
Example #10
0
 def _4dom_validateNode(self, newNode):
     if not newNode.nodeType in self.__class__._allowedChildren:
         raise HierarchyRequestErr()
     self._4dom_raiseIfAncestor(newNode)
     if self.ownerDocument != newNode.ownerDocument:
         raise WrongDocumentErr()