Lines Matching +full:node +full:- +full:version
24 # This is used by the ID-cache invalidation checks; the list isn't
26 # DOCUMENT_NODE or DOCUMENT_FRAGMENT_NODE. (The node being checked is
27 # the node being added or removed, not the node being modified.)
29 _nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE,
30 xml.dom.Node.ENTITY_REFERENCE_NODE)
33 class Node(xml.dom.Node): class
34 namespaceURI = None # this is non-null only for elements and attributes
40 prefix = EMPTY_PREFIX # non-null only for NS elements and attributes
56 if self.nodeType == Node.DOCUMENT_NODE:
78 return self.childNodes[-1]
104 node = self.childNodes[index-1]
105 node.nextSibling = newChild
106 newChild.previousSibling = node
112 def appendChild(self, node): argument
113 if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
114 for c in tuple(node.childNodes):
117 return node
118 if node.nodeType not in self._child_node_types:
120 "%s cannot be child of %s" % (repr(node), repr(self)))
121 elif node.nodeType in _nodeTypes_with_children:
123 if node.parentNode is not None:
124 node.parentNode.removeChild(node)
125 _append_child(self, node)
126 node.nextSibling = None
127 return node
180 if child.nodeType == Node.TEXT_NODE:
182 # empty text node; discard
184 L[-1].nextSibling = child.nextSibling
188 elif L and L[-1].nodeType == child.nodeType:
189 # collapse text node
190 node = L[-1]
191 node.data = node.data + child.data
192 node.nextSibling = child.nextSibling
194 child.nextSibling.previousSibling = node
200 if child.nodeType == Node.ELEMENT_NODE:
207 def isSupported(self, feature, version): argument
208 return self.ownerDocument.implementation.hasFeature(feature, version)
211 # Overridden in Element and Attr where localName can be Non-Null
214 # Node interfaces from Level 3 (WD 9 April 2002)
259 # minidom-specific API:
270 defproperty(Node, "firstChild", doc="First child node, or None.")
271 defproperty(Node, "lastChild", doc="Last child node, or None.")
272 defproperty(Node, "localName", doc="Namespace-local name of this node.")
275 def _append_child(self, node): argument
279 last = childNodes[-1]
280 node.__dict__["previousSibling"] = last
281 last.__dict__["nextSibling"] = node
282 childNodes.append(node)
283 node.__dict__["parentNode"] = self
285 def _in_document(node): argument
286 # return True iff node is part of a document tree
287 while node is not None:
288 if node.nodeType == Node.DOCUMENT_NODE:
290 node = node.parentNode
301 for node in parent.childNodes:
302 if node.nodeType == Node.ELEMENT_NODE and \
303 (name == "*" or node.tagName == name):
304 rc.append(node)
305 _get_elements_by_tagName_helper(node, name, rc)
309 for node in parent.childNodes:
310 if node.nodeType == Node.ELEMENT_NODE:
311 if ((localName == "*" or node.localName == localName) and
312 (nsURI == "*" or node.namespaceURI == nsURI)):
313 rc.append(node)
314 _get_elements_by_tagName_ns_helper(node, nsURI, localName, rc)
317 class DocumentFragment(Node):
318 nodeType = Node.DOCUMENT_FRAGMENT_NODE
319 nodeName = "#document-fragment"
323 _child_node_types = (Node.ELEMENT_NODE,
324 Node.TEXT_NODE,
325 Node.CDATA_SECTION_NODE,
326 Node.ENTITY_REFERENCE_NODE,
327 Node.PROCESSING_INSTRUCTION_NODE,
328 Node.COMMENT_NODE,
329 Node.NOTATION_NODE)
335 class Attr(Node):
336 nodeType = Node.ATTRIBUTE_NODE
342 _child_node_types = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE)
353 # Add the single child node that represents the value of the attr
359 return self.nodeName.split(":", 1)[-1]
413 elem._magic_id_nodes -= 1
414 self.ownerDocument._magic_id_count -= 1
450 defproperty(Attr, "localName", doc="Namespace-local name of this attribute.")
481 for node in self._attrs.values():
482 L.append((node.nodeName, node.value))
487 for node in self._attrs.values():
488 L.append(((node.namespaceURI, node.localName), node.value))
528 node = self._attrs[attname]
530 node = Attr(attname)
531 node.ownerDocument = self._ownerElement.ownerDocument
532 self.setNamedItem(node)
533 node.value = value
537 node = value
538 self.setNamedItem(node)
576 def setNamedItem(self, node): argument
577 if not isinstance(node, Attr):
579 "%s cannot be child of %s" % (repr(node), repr(self)))
580 old = self._attrs.get(node.name)
583 self._attrs[node.name] = node
584 self._attrsNS[(node.namespaceURI, node.localName)] = node
585 node.ownerElement = self._ownerElement
586 _clear_id_cache(node.ownerElement)
589 def setNamedItemNS(self, node): argument
590 return self.setNamedItem(node)
593 node = self[attname_or_tuple]
594 _clear_id_cache(node.ownerElement)
595 node.unlink()
630 class Element(Node):
631 nodeType = Node.ELEMENT_NODE
637 _child_node_types = (Node.ELEMENT_NODE,
638 Node.PROCESSING_INSTRUCTION_NODE,
639 Node.COMMENT_NODE,
640 Node.TEXT_NODE,
641 Node.CDATA_SECTION_NODE,
642 Node.ENTITY_REFERENCE_NODE)
651 self._attrs = {} # attributes are double-indexed:
652 self._attrsNS = {} # tagName -> Attribute
653 # URI,localName -> Attribute
660 return self.tagName.split(":", 1)[-1]
670 Node.unlink(self)
729 raise xml.dom.InuseAttributeErr("attribute node already owned")
739 # It might have already been part of this node, in which case
761 def removeAttributeNode(self, node): argument
762 if node is None:
765 self._attrs[node.name]
769 node.unlink()
770 # Restore this since the node is still useful and otherwise
772 node.ownerDocument = self.ownerDocument
809 self.childNodes[0].nodeType == Node.TEXT_NODE):
813 for node in self.childNodes:
814 node.writexml(writer, indent+addindent, addindent, newl)
853 doc="Namespace-local name of this element.")
868 """Mixin that makes childless-ness easy to implement and avoids
869 the complexity of the Node methods that deal with children.
883 def appendChild(self, node): argument
907 class ProcessingInstruction(Childless, Node):
908 nodeType = Node.PROCESSING_INSTRUCTION_NODE
938 class CharacterData(Childless, Node):
964 return '<DOM %s node "%r%s">' % (
1015 # XXX this does not work, CharacterData is an old-style class
1018 nodeType = Node.TEXT_NODE
1046 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1053 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1066 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1076 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1103 doc="True iff this text node contains only whitespace"
1106 doc="The text of all logically-adjacent text nodes.")
1109 def _get_containing_element(node): argument
1110 c = node.parentNode
1112 if c.nodeType == Node.ELEMENT_NODE:
1117 def _get_containing_entref(node): argument
1118 c = node.parentNode
1120 if c.nodeType == Node.ENTITY_REFERENCE_NODE:
1127 nodeType = Node.COMMENT_NODE
1134 if "--" in self.data:
1135 raise ValueError("'--' is not allowed in a comment node")
1136 writer.write("%s<!--%s-->%s" % (indent, self.data, newl))
1142 # XXX this does not work, Text is an old-style class
1145 nodeType = Node.CDATA_SECTION_NODE
1146 nodeName = "#cdata-section"
1179 node = self.getNamedItemNS(*name_or_tuple)
1181 node = self.getNamedItem(name_or_tuple)
1182 if node is None:
1184 return node
1196 "NamedNodeMap instance is read-only")
1200 "NamedNodeMap instance is read-only")
1202 def setNamedItem(self, node): argument
1204 "NamedNodeMap instance is read-only")
1206 def setNamedItemNS(self, node): argument
1208 "NamedNodeMap instance is read-only")
1221 """Mix-in class that supports the publicId and systemId attributes."""
1223 # XXX this does not work, this is an old-style class
1236 class DocumentType(Identified, Childless, Node):
1237 nodeType = Node.DOCUMENT_TYPE_NODE
1274 entity.version = e.version
1296 class Entity(Identified, Node):
1298 nodeType = Node.ENTITY_NODE
1303 version = None variable in Entity
1318 return self.version
1322 "cannot append children to an entity node")
1326 "cannot insert children below an entity node")
1330 "cannot remove children from an entity node")
1334 "cannot replace children of an entity node")
1336 class Notation(Identified, Childless, Node):
1337 nodeType = Node.NOTATION_NODE
1352 ("ls-load", "3.0"),
1353 ("ls-load", None),
1356 def hasFeature(self, feature, version): argument
1357 if version == "":
1358 version = None
1359 return (feature.lower(), version) in self._features
1425 """Object that represents content-model information for an element.
1453 """Returns true iff the named attribute is a DTD-style ID."""
1457 """Returns true iff the identified attribute is a DTD-style ID."""
1466 def _clear_id_cache(node): argument
1467 if node.nodeType == Node.DOCUMENT_NODE:
1468 node._id_cache.clear()
1469 node._id_search_stack = None
1470 elif _in_document(node):
1471 node.ownerDocument._id_cache.clear()
1472 node.ownerDocument._id_search_stack= None
1474 class Document(Node, DocumentLS):
1475 _child_node_types = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE,
1476 Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE)
1478 nodeType = Node.DOCUMENT_NODE
1493 version = None variable in Document
1502 # mapping of (namespaceURI, localName) -> ElementInfo
1503 # and tagName -> ElementInfo
1537 return self.version
1539 def appendChild(self, node): argument
1540 if node.nodeType not in self._child_node_types:
1542 "%s cannot be child of %s" % (repr(node), repr(self)))
1543 if node.parentNode is not None:
1546 # end up re-ordered to the end.
1547 node.parentNode.removeChild(node)
1549 if node.nodeType == Node.ELEMENT_NODE \
1553 return Node.appendChild(self, node)
1568 for node in self.childNodes:
1569 if node.nodeType == Node.ELEMENT_NODE:
1570 return node
1576 Node.unlink(self)
1584 clone.version = self.version
1589 if childclone.nodeType == Node.DOCUMENT_NODE:
1591 elif childclone.nodeType == Node.DOCUMENT_TYPE_NODE:
1611 raise TypeError, "node contents must be a string"
1619 raise TypeError, "node contents must be a string"
1654 # A couple of implementation-specific helpers to create node types
1680 # no matching node.
1685 node = stack.pop()
1687 stack.extend([child for child in node.childNodes
1689 # check this node
1690 info = self._get_elem_info(node)
1695 for attr in node.attributes.values():
1698 self._id_cache[attr.value] = node
1700 result = node
1701 elif not node._magic_id_nodes:
1704 self._id_cache[attr.value] = node
1706 result = node
1707 elif not node._magic_id_nodes:
1710 self._id_cache[attr.value] = node
1712 result = node
1713 elif node._magic_id_nodes == 1:
1715 elif node._magic_id_nodes:
1716 for attr in node.attributes.values():
1718 self._id_cache[attr.value] = node
1720 result = node
1732 def isSupported(self, feature, version): argument
1733 return self.implementation.hasFeature(feature, version)
1735 def importNode(self, node, deep): argument
1736 if node.nodeType == Node.DOCUMENT_NODE:
1738 elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
1740 return _clone_node(node, deep, self)
1745 writer.write('<?xml version="1.0" ?>'+newl)
1747 writer.write('<?xml version="1.0" encoding="%s"?>%s' % (encoding, newl))
1748 for node in self.childNodes:
1749 node.writexml(writer, indent, addindent, newl)
1758 if n.nodeType not in (Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE):
1771 and n.nodeType == Node.ATTRIBUTE_NODE):
1779 if n.nodeType == Node.ATTRIBUTE_NODE:
1792 if n.nodeType == Node.ELEMENT_NODE:
1795 # attribute node
1803 # we're re-using the existing node. The draft spec has been
1805 # new node is created."
1809 doc="Top-level element of this document.")
1812 def _clone_node(node, deep, newOwnerDocument): argument
1814 Clone a node and give it the new owner document.
1815 Called by Node.cloneNode and Document.importNode
1817 if node.ownerDocument.isSameNode(newOwnerDocument):
1821 if node.nodeType == Node.ELEMENT_NODE:
1822 clone = newOwnerDocument.createElementNS(node.namespaceURI,
1823 node.nodeName)
1824 for attr in node.attributes.values():
1830 for child in node.childNodes:
1834 elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE:
1837 for child in node.childNodes:
1841 elif node.nodeType == Node.TEXT_NODE:
1842 clone = newOwnerDocument.createTextNode(node.data)
1843 elif node.nodeType == Node.CDATA_SECTION_NODE:
1844 clone = newOwnerDocument.createCDATASection(node.data)
1845 elif node.nodeType == Node.PROCESSING_INSTRUCTION_NODE:
1846 clone = newOwnerDocument.createProcessingInstruction(node.target,
1847 node.data)
1848 elif node.nodeType == Node.COMMENT_NODE:
1849 clone = newOwnerDocument.createComment(node.data)
1850 elif node.nodeType == Node.ATTRIBUTE_NODE:
1851 clone = newOwnerDocument.createAttributeNS(node.namespaceURI,
1852 node.nodeName)
1854 clone.value = node.value
1855 elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
1856 assert node.ownerDocument is not newOwnerDocument
1859 node.name, node.publicId, node.systemId)
1864 for n in node.notations._seq:
1870 for e in node.entities._seq:
1875 entity.version = e.version
1884 raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node))
1889 if hasattr(node, '_call_user_data_handler'):
1890 node._call_user_data_handler(operation, node, clone)