MCPcopy Index your code
hub / github.com/python/cpython / start_element_handler

Method start_element_handler

Lib/xml/dom/expatbuilder.py:733–778  ·  view source on GitHub ↗
(self, name, attributes)

Source from the content-addressed store, hash-verified

731 self._ns_ordered_prefixes.append((prefix, uri))
732
733 def start_element_handler(self, name, attributes):
734 if ' ' in name:
735 uri, localname, prefix, qname = _parse_ns_name(self, name)
736 else:
737 uri = EMPTY_NAMESPACE
738 qname = name
739 localname = None
740 prefix = EMPTY_PREFIX
741 node = minidom.Element(qname, uri, prefix, localname)
742 node.ownerDocument = self.document
743 _append_child(self.curNode, node)
744 self.curNode = node
745
746 if self._ns_ordered_prefixes:
747 for prefix, uri in self._ns_ordered_prefixes:
748 if prefix:
749 a = minidom.Attr(_intern(self, 'xmlns:' + prefix),
750 XMLNS_NAMESPACE, prefix, "xmlns")
751 else:
752 a = minidom.Attr("xmlns", XMLNS_NAMESPACE,
753 "xmlns", EMPTY_PREFIX)
754 a.value = uri
755 a.ownerDocument = self.document
756 _set_attribute_node(node, a)
757 del self._ns_ordered_prefixes[:]
758
759 if attributes:
760 node._ensure_attributes()
761 _attrs = node._attrs
762 _attrsNS = node._attrsNS
763 for i in range(0, len(attributes), 2):
764 aname = attributes[i]
765 value = attributes[i+1]
766 if ' ' in aname:
767 uri, localname, prefix, qname = _parse_ns_name(self, aname)
768 a = minidom.Attr(qname, uri, localname, prefix)
769 _attrs[qname] = a
770 _attrsNS[(uri, localname)] = a
771 else:
772 a = minidom.Attr(aname, EMPTY_NAMESPACE,
773 aname, EMPTY_PREFIX)
774 _attrs[aname] = a
775 _attrsNS[(EMPTY_NAMESPACE, aname)] = a
776 a.ownerDocument = self.document
777 a.value = value
778 a.ownerElement = node
779
780 if __debug__:
781 # This only adds some asserts to the original

Callers

nothing calls this directly

Calls 5

_ensure_attributesMethod · 0.95
_append_childFunction · 0.90
_set_attribute_nodeFunction · 0.90
_parse_ns_nameFunction · 0.85
_internFunction · 0.85

Tested by

no test coverage detected