| 672 | _no_type = TypeInfo(None, None) |
| 673 | |
| 674 | class Element(Node): |
| 675 | __slots__=('ownerDocument', 'parentNode', 'tagName', 'nodeName', 'prefix', |
| 676 | 'namespaceURI', '_localName', 'childNodes', '_attrs', '_attrsNS', |
| 677 | 'nextSibling', 'previousSibling') |
| 678 | nodeType = Node.ELEMENT_NODE |
| 679 | nodeValue = None |
| 680 | schemaType = _no_type |
| 681 | |
| 682 | _magic_id_nodes = 0 |
| 683 | |
| 684 | _child_node_types = (Node.ELEMENT_NODE, |
| 685 | Node.PROCESSING_INSTRUCTION_NODE, |
| 686 | Node.COMMENT_NODE, |
| 687 | Node.TEXT_NODE, |
| 688 | Node.CDATA_SECTION_NODE, |
| 689 | Node.ENTITY_REFERENCE_NODE) |
| 690 | |
| 691 | def __init__(self, tagName, namespaceURI=EMPTY_NAMESPACE, prefix=None, |
| 692 | localName=None): |
| 693 | self.ownerDocument = None |
| 694 | self.parentNode = None |
| 695 | self.tagName = self.nodeName = tagName |
| 696 | self.prefix = prefix |
| 697 | self.namespaceURI = namespaceURI |
| 698 | self.childNodes = NodeList() |
| 699 | self.nextSibling = self.previousSibling = None |
| 700 | |
| 701 | # Attribute dictionaries are lazily created |
| 702 | # attributes are double-indexed: |
| 703 | # tagName -> Attribute |
| 704 | # URI,localName -> Attribute |
| 705 | # in the future: consider lazy generation |
| 706 | # of attribute objects this is too tricky |
| 707 | # for now because of headaches with |
| 708 | # namespaces. |
| 709 | self._attrs = None |
| 710 | self._attrsNS = None |
| 711 | |
| 712 | def _ensure_attributes(self): |
| 713 | if self._attrs is None: |
| 714 | self._attrs = {} |
| 715 | self._attrsNS = {} |
| 716 | |
| 717 | def _get_localName(self): |
| 718 | try: |
| 719 | return self._localName |
| 720 | except AttributeError: |
| 721 | return self.tagName.split(":", 1)[-1] |
| 722 | |
| 723 | def _get_tagName(self): |
| 724 | return self.tagName |
| 725 | |
| 726 | def unlink(self): |
| 727 | if self._attrs is not None: |
| 728 | for attr in list(self._attrs.values()): |
| 729 | attr.unlink() |
| 730 | self._attrs = None |
| 731 | self._attrsNS = None |
no outgoing calls
searching dependent graphs…