• Home
  • Raw
  • Download

Lines Matching +full:node +full:- +full:version

25 # This is used by the ID-cache invalidation checks; the list isn't
27 # DOCUMENT_NODE or DOCUMENT_FRAGMENT_NODE. (The node being checked is
28 # the node being added or removed, not the node being modified.)
30 _nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE,
31 xml.dom.Node.ENTITY_REFERENCE_NODE)
34 class Node(xml.dom.Node): class
35 namespaceURI = None # this is non-null only for elements and attributes
41 prefix = EMPTY_PREFIX # non-null only for NS elements and attributes
58 if self.nodeType == Node.DOCUMENT_NODE:
80 return self.childNodes[-1]
106 node = self.childNodes[index-1]
107 node.nextSibling = newChild
108 newChild.previousSibling = node
114 def appendChild(self, node): argument
115 if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
116 for c in tuple(node.childNodes):
119 return node
120 if node.nodeType not in self._child_node_types:
122 "%s cannot be child of %s" % (repr(node), repr(self)))
123 elif node.nodeType in _nodeTypes_with_children:
125 if node.parentNode is not None:
126 node.parentNode.removeChild(node)
127 _append_child(self, node)
128 node.nextSibling = None
129 return node
182 if child.nodeType == Node.TEXT_NODE:
184 # empty text node; discard
186 L[-1].nextSibling = child.nextSibling
190 elif L and L[-1].nodeType == child.nodeType:
191 # collapse text node
192 node = L[-1]
193 node.data = node.data + child.data
194 node.nextSibling = child.nextSibling
196 child.nextSibling.previousSibling = node
202 if child.nodeType == Node.ELEMENT_NODE:
209 def isSupported(self, feature, version): argument
210 return self.ownerDocument.implementation.hasFeature(feature, version)
213 # Overridden in Element and Attr where localName can be Non-Null
216 # Node interfaces from Level 3 (WD 9 April 2002)
261 # minidom-specific API:
272 # A Node is its own context manager, to ensure that an unlink() call occurs.
280 defproperty(Node, "firstChild", doc="First child node, or None.")
281 defproperty(Node, "lastChild", doc="Last child node, or None.")
282 defproperty(Node, "localName", doc="Namespace-local name of this node.")
285 def _append_child(self, node): argument
289 last = childNodes[-1]
290 node.previousSibling = last
291 last.nextSibling = node
292 childNodes.append(node)
293 node.parentNode = self
295 def _in_document(node): argument
296 # return True iff node is part of a document tree
297 while node is not None:
298 if node.nodeType == Node.DOCUMENT_NODE:
300 node = node.parentNode
311 for node in parent.childNodes:
312 if node.nodeType == Node.ELEMENT_NODE and \
313 (name == "*" or node.tagName == name):
314 rc.append(node)
315 _get_elements_by_tagName_helper(node, name, rc)
319 for node in parent.childNodes:
320 if node.nodeType == Node.ELEMENT_NODE:
321 if ((localName == "*" or node.localName == localName) and
322 (nsURI == "*" or node.namespaceURI == nsURI)):
323 rc.append(node)
324 _get_elements_by_tagName_ns_helper(node, nsURI, localName, rc)
327 class DocumentFragment(Node):
328 nodeType = Node.DOCUMENT_FRAGMENT_NODE
329 nodeName = "#document-fragment"
333 _child_node_types = (Node.ELEMENT_NODE,
334 Node.TEXT_NODE,
335 Node.CDATA_SECTION_NODE,
336 Node.ENTITY_REFERENCE_NODE,
337 Node.PROCESSING_INSTRUCTION_NODE,
338 Node.COMMENT_NODE,
339 Node.NOTATION_NODE)
345 class Attr(Node):
348 nodeType = Node.ATTRIBUTE_NODE
353 _child_node_types = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE)
365 # Add the single child node that represents the value of the attr
374 return self.nodeName.split(":", 1)[-1]
432 elem._magic_id_nodes -= 1
433 self.ownerDocument._magic_id_count -= 1
469 defproperty(Attr, "localName", doc="Namespace-local name of this attribute.")
500 for node in self._attrs.values():
501 L.append((node.nodeName, node.value))
506 for node in self._attrs.values():
507 L.append(((node.namespaceURI, node.localName), node.value))
534 return (id(self) > id(other)) - (id(self) < id(other))
561 node = self._attrs[attname]
563 node = Attr(attname)
564 node.ownerDocument = self._ownerElement.ownerDocument
565 self.setNamedItem(node)
566 node.value = value
570 node = value
571 self.setNamedItem(node)
609 def setNamedItem(self, node): argument
610 if not isinstance(node, Attr):
612 "%s cannot be child of %s" % (repr(node), repr(self)))
613 old = self._attrs.get(node.name)
616 self._attrs[node.name] = node
617 self._attrsNS[(node.namespaceURI, node.localName)] = node
618 node.ownerElement = self._ownerElement
619 _clear_id_cache(node.ownerElement)
622 def setNamedItemNS(self, node): argument
623 return self.setNamedItem(node)
626 node = self[attname_or_tuple]
627 _clear_id_cache(node.ownerElement)
628 node.unlink()
664 class Element(Node):
668 nodeType = Node.ELEMENT_NODE
674 _child_node_types = (Node.ELEMENT_NODE,
675 Node.PROCESSING_INSTRUCTION_NODE,
676 Node.COMMENT_NODE,
677 Node.TEXT_NODE,
678 Node.CDATA_SECTION_NODE,
679 Node.ENTITY_REFERENCE_NODE)
691 # attributes are double-indexed:
692 # tagName -> Attribute
693 # URI,localName -> Attribute
710 return self.tagName.split(":", 1)[-1]
721 Node.unlink(self)
788 raise xml.dom.InuseAttributeErr("attribute node already owned")
799 # It might have already been part of this node, in which case
825 def removeAttributeNode(self, node): argument
826 if node is None:
829 self._attrs[node.name]
833 node.unlink()
834 # Restore this since the node is still useful and otherwise
836 node.ownerDocument = self.ownerDocument
837 return node
872 """Write an XML element to a file-like object
892 Node.TEXT_NODE, Node.CDATA_SECTION_NODE)):
896 for node in self.childNodes:
897 node.writexml(writer, indent+addindent, addindent, newl)
937 doc="Namespace-local name of this element.")
952 """Mixin that makes childless-ness easy to implement and avoids
953 the complexity of the Node methods that deal with children.
968 def appendChild(self, node): argument
992 class ProcessingInstruction(Childless, Node):
993 nodeType = Node.PROCESSING_INSTRUCTION_NODE
1018 class CharacterData(Childless, Node):
1025 Node.__init__(self)
1044 return '<DOM %s node "%r%s">' % (
1095 nodeType = Node.TEXT_NODE
1123 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1130 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1143 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1153 if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE):
1178 doc="True iff this text node contains only whitespace"
1181 doc="The text of all logically-adjacent text nodes.")
1184 def _get_containing_element(node): argument
1185 c = node.parentNode
1187 if c.nodeType == Node.ELEMENT_NODE:
1192 def _get_containing_entref(node): argument
1193 c = node.parentNode
1195 if c.nodeType == Node.ENTITY_REFERENCE_NODE:
1202 nodeType = Node.COMMENT_NODE
1210 if "--" in self.data:
1211 raise ValueError("'--' is not allowed in a comment node")
1212 writer.write("%s<!--%s-->%s" % (indent, self.data, newl))
1218 nodeType = Node.CDATA_SECTION_NODE
1219 nodeName = "#cdata-section"
1252 node = self.getNamedItemNS(*name_or_tuple)
1254 node = self.getNamedItem(name_or_tuple)
1255 if node is None:
1257 return node
1269 "NamedNodeMap instance is read-only")
1273 "NamedNodeMap instance is read-only")
1275 def setNamedItem(self, node): argument
1277 "NamedNodeMap instance is read-only")
1279 def setNamedItemNS(self, node): argument
1281 "NamedNodeMap instance is read-only")
1294 """Mix-in class that supports the publicId and systemId attributes."""
1308 class DocumentType(Identified, Childless, Node):
1309 nodeType = Node.DOCUMENT_TYPE_NODE
1346 entity.version = e.version
1368 class Entity(Identified, Node):
1370 nodeType = Node.ENTITY_NODE
1375 version = None variable in Entity
1390 return self.version
1394 "cannot append children to an entity node")
1398 "cannot insert children below an entity node")
1402 "cannot remove children from an entity node")
1406 "cannot replace children of an entity node")
1408 class Notation(Identified, Childless, Node):
1409 nodeType = Node.NOTATION_NODE
1424 ("ls-load", "3.0"),
1425 ("ls-load", None),
1428 def hasFeature(self, feature, version): argument
1429 if version == "":
1430 version = None
1431 return (feature.lower(), version) in self._features
1497 """Object that represents content-model information for an element.
1525 """Returns true iff the named attribute is a DTD-style ID."""
1529 """Returns true iff the identified attribute is a DTD-style ID."""
1538 def _clear_id_cache(node): argument
1539 if node.nodeType == Node.DOCUMENT_NODE:
1540 node._id_cache.clear()
1541 node._id_search_stack = None
1542 elif _in_document(node):
1543 node.ownerDocument._id_cache.clear()
1544 node.ownerDocument._id_search_stack= None
1546 class Document(Node, DocumentLS):
1549 _child_node_types = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE,
1550 Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE)
1553 nodeType = Node.DOCUMENT_NODE
1566 version = None variable in Document
1576 # mapping of (namespaceURI, localName) -> ElementInfo
1577 # and tagName -> ElementInfo
1611 return self.version
1613 def appendChild(self, node): argument
1614 if node.nodeType not in self._child_node_types:
1616 "%s cannot be child of %s" % (repr(node), repr(self)))
1617 if node.parentNode is not None:
1620 # end up re-ordered to the end.
1621 node.parentNode.removeChild(node)
1623 if node.nodeType == Node.ELEMENT_NODE \
1627 return Node.appendChild(self, node)
1642 for node in self.childNodes:
1643 if node.nodeType == Node.ELEMENT_NODE:
1644 return node
1650 Node.unlink(self)
1658 clone.version = self.version
1663 if childclone.nodeType == Node.DOCUMENT_NODE:
1665 elif childclone.nodeType == Node.DOCUMENT_TYPE_NODE:
1685 raise TypeError("node contents must be a string")
1693 raise TypeError("node contents must be a string")
1728 # A couple of implementation-specific helpers to create node types
1754 # no matching node.
1759 node = stack.pop()
1761 stack.extend([child for child in node.childNodes
1763 # check this node
1764 info = self._get_elem_info(node)
1769 for attr in node.attributes.values():
1772 self._id_cache[attr.value] = node
1774 result = node
1775 elif not node._magic_id_nodes:
1778 self._id_cache[attr.value] = node
1780 result = node
1781 elif not node._magic_id_nodes:
1784 self._id_cache[attr.value] = node
1786 result = node
1787 elif node._magic_id_nodes == 1:
1789 elif node._magic_id_nodes:
1790 for attr in node.attributes.values():
1792 self._id_cache[attr.value] = node
1794 result = node
1806 def isSupported(self, feature, version): argument
1807 return self.implementation.hasFeature(feature, version)
1809 def importNode(self, node, deep): argument
1810 if node.nodeType == Node.DOCUMENT_NODE:
1812 elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
1814 return _clone_node(node, deep, self)
1825 writer.write(f'<?xml version="1.0" {" ".join(declarations)}?>{newl}')
1827 for node in self.childNodes:
1828 node.writexml(writer, indent, addindent, newl)
1837 if n.nodeType not in (Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE):
1850 and n.nodeType == Node.ATTRIBUTE_NODE):
1858 if n.nodeType == Node.ATTRIBUTE_NODE:
1869 if n.nodeType == Node.ELEMENT_NODE:
1872 # attribute node
1880 # we're re-using the existing node. The draft spec has been
1882 # new node is created."
1886 doc="Top-level element of this document.")
1889 def _clone_node(node, deep, newOwnerDocument): argument
1891 Clone a node and give it the new owner document.
1892 Called by Node.cloneNode and Document.importNode
1894 if node.ownerDocument.isSameNode(newOwnerDocument):
1898 if node.nodeType == Node.ELEMENT_NODE:
1899 clone = newOwnerDocument.createElementNS(node.namespaceURI,
1900 node.nodeName)
1901 for attr in node.attributes.values():
1907 for child in node.childNodes:
1911 elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE:
1914 for child in node.childNodes:
1918 elif node.nodeType == Node.TEXT_NODE:
1919 clone = newOwnerDocument.createTextNode(node.data)
1920 elif node.nodeType == Node.CDATA_SECTION_NODE:
1921 clone = newOwnerDocument.createCDATASection(node.data)
1922 elif node.nodeType == Node.PROCESSING_INSTRUCTION_NODE:
1923 clone = newOwnerDocument.createProcessingInstruction(node.target,
1924 node.data)
1925 elif node.nodeType == Node.COMMENT_NODE:
1926 clone = newOwnerDocument.createComment(node.data)
1927 elif node.nodeType == Node.ATTRIBUTE_NODE:
1928 clone = newOwnerDocument.createAttributeNS(node.namespaceURI,
1929 node.nodeName)
1931 clone.value = node.value
1932 elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
1933 assert node.ownerDocument is not newOwnerDocument
1936 node.name, node.publicId, node.systemId)
1941 for n in node.notations._seq:
1947 for e in node.entities._seq:
1952 entity.version = e.version
1961 raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node))
1966 if hasattr(node, '_call_user_data_handler'):
1967 node._call_user_data_handler(operation, node, clone)