def startElement(self, tag, attributes):
    """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.
    """
    # If this is the document node, we may have to look for a context stack
    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

    # Display a kinder error on a common mistake
    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

    # Verify no unexpected attributes
    if attributes:
      text = ''
      for attr in attributes.keys():
        # The document node will probably have namespaces
        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))

    # Switch contexts
    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(tag % 'Can not accept tag "%s" where it appears.')
      raise SchemaError
  #end def startElement
dataset/ETHPy150Open benoitc/gunicorn/docs/sitemap_gen.py/InputSitemap.startElement/swapped operands of `%`