code: @Override
      public void startElement( String uri, String localName, String qName, Attributes attributes )
          throws SAXException
      {
          flushCharacters();
          IndentCheckSaxHandler.ElementEntry currentEntry = new ElementEntry( qName, lastIndent );
          if ( !stack.isEmpty() )
          {
              IndentCheckSaxHandler.ElementEntry parentEntry = stack.peek();
              /*
               * note that we use parentEntry.expectedIndent rather than parentEntry.foundIndent this is to make the
               * messages more useful
               */
              int indentDiff = currentEntry.foundIndent.size - parentEntry.expectedIndent.size;
              int expectedIndent = parentEntry.expectedIndent.size + indentSize;
              if ( indentDiff == 0 && currentEntry.foundIndent.lineNumber == parentEntry.foundIndent.lineNumber )
              {
                  /*
                   * Zero foundIndent acceptable only if current is on the same line as parent This is OK, therefore do
                   * nothing
                   */
              }
              else if ( indentDiff != indentSize )
              {
                  /* generally unexpected foundIndent */
                  int opValue = expectedIndent - currentEntry.foundIndent.size;
                  String op = opValue > 0 ? "Insert" : "Delete";
                  String message = op + " " + Math.abs( opValue ) + " spaces. Expected " + expectedIndent + " found "
                      + currentEntry.foundIndent.size + " spaces before start element <" + currentEntry.elementName + ">";
  
                  XmlFormatViolation violation =
                      new XmlFormatViolation( file, locator.getLineNumber(), locator.getColumnNumber(), message );
                  violationHandler.handle( violation );
  
                  /* reset the expected indent in the entry we'll push */
                  currentEntry =
                      new ElementEntry( qName, lastIndent, new Indent( lastIndent.lineNumber, expectedIndent ) );
              }
          }
          stack.push( currentEntry );
      }
docs: Checks indentation for a start element.
  
  @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
  org.xml.sax.Attributes)