'XML Parser callback. Used internally'

def starttag(self, tag, attrs):

    self.check_data_buffer()
    self._inc_depth()
    self.DEBUG(DBG_NODEBUILDER, ('DEPTH    ->    %i    ,    tag    ->    %s,    attrs    ->    %s' % (self.__depth, tag, `attrs`)), 'down')
    if (self.__depth == self._dispatch_depth):
        if (not self._mini_dom):
            self._mini_dom = Node(tag=tag, attrs=attrs, nsp=self._document_nsp, node_built=True)
        else:
            Node.__init__(self._mini_dom, tag=tag, attrs=attrs, nsp=self._document_nsp, node_built=True)
        self._ptr = self._mini_dom
    elif (self.__depth > self._dispatch_depth):
        self._ptr.kids.append(Node(tag=tag, parent=self._ptr, attrs=attrs, node_built=True))
        self._ptr = self._ptr.kids[(-1)]
    if (self.__depth == 1):
        self._document_attrs = {}
        self._document_nsp = {}
        (nsp, name) = ([''] + tag.split(':'))[(-2):]
        for (attr, val) in attrs.items():
            if (attr == 'xmlns'):
                self._document_nsp[u''] = val
            elif attr.startswith('xmlns:'):
                self._document_nsp[attr[6:]] = val
            else:
                self._document_attrs[attr] = val
        ns = self._document_nsp.get(nsp, 'http://www.gajim.org/xmlns/undeclared-root')
        try:
            self.stream_header_received(ns, name, attrs)
        except ValueError as e:
            self._document_attrs = None
            raise ValueError(str(e))
    if ((not self.last_is_data) and self._ptr.parent):
        self._ptr.parent.data.append('')
    self.last_is_data = 0
