code: public static void addOrSetAttribute(final AttributesImpl atts, final String uri, final String localName,
              final String qName, final String type, final String value) {
          final int i = atts.getIndex(qName);
          if (i != -1) {
              atts.setAttribute(i, uri, localName, qName, type, value);
          } else {
              atts.addAttribute(uri, localName, qName, type, value);
          }
      }
docs: Add or set attribute.
  
  @param atts attributes
  @param uri namespace URI
  @param localName local name
  @param qName qualified name
  @param type attribute type
  @param value attribute value