'SAX processing, called per node in the config stream.
As long as the new tag is legal in our current context, this
becomes an Open call on one context deeper.'

def startElement(self, tag, attributes):

    if ((self._current < 0) and (not self._contexts)):
        assert (self._contexts_idx and self._contexts_stm)
        if (tag == 'urlset'):
            self._contexts = self._contexts_stm
        elif (tag == 'sitemapindex'):
            self._contexts = self._contexts_idx
            output.Log('File    is    a    Sitemap    index.', 2)
        else:
            output.Error('The    document    appears    to    be    neither    a    Sitemap    nor    a    Sitemap    index.')
            raise SchemaError
    if ((self._current < 0) and (self._contexts == self._contexts_stm) and (tag == 'sitemapindex')):
        output.Error('A    Sitemap    index    can    not    refer    to    another    Sitemap    index.')
        raise SchemaError
    if attributes:
        text = ''
        for attr in attributes.keys():
            if (self._current < 0):
                if (attr.find('xmlns') >= 0):
                    continue
                if (attr.find('xsi') >= 0):
                    continue
            if text:
                text = (text + ',    ')
            text = (text + attr)
        if text:
            output.Warn(('Did    not    expect    any    attributes    on    any    tag,    instead    tag    "%s"    had    attributes:    %s' % (tag, text)))
    if ((self._current < 0) or self._contexts[self._current].AcceptTag(tag)):
        self._current = (self._current + 1)
        assert (self._current < len(self._contexts))
        self._contexts[self._current].Open()
    else:
        output.Error(('Can    not    accept    tag    "%s"    where    it    appears.' % tag))
        raise SchemaError
