/**
   * Start Element handler
   *
   * @param namespaceURI namespace URI
   * @param lName local name
   * @param qName qualified name
   * @param attrs attributes
   */
  public void startElement(String namespaceURI, String lName, String qName, Attributes attrs)
      throws SAXDigiDocException {
    String tName = qName;
    if (tName.indexOf(":") != -1) tName = qName.substring(qName.indexOf(":") + 1);
    if (m_logger.isDebugEnabled())
      m_logger.debug(
          "Start Element: "
              + tName
              + " qname: "
              + qName
              + " lname: "
              + lName
              + " uri: "
              + namespaceURI);
    m_tags.push(tName);
    if (tName.equals("KeyName")
        || tName.equals("CarriedKeyName")
        || tName.equals("X509Certificate")
        || tName.equals("CipherValue")
        || tName.equals("EncryptionProperty")) m_sbCollectChars = new StringBuffer();

    // <EncryptedData>
    if (tName.equals("EncryptedData")) {
      String str = findAtributeValue(attrs, "xmlns");
      try {
        m_doc = new EncryptedData(str);
        str = findAtributeValue(attrs, "Id");
        if (str != null) m_doc.setId(str);
        str = findAtributeValue(attrs, "Type");
        if (str != null) m_doc.setType(str);
        str = findAtributeValue(attrs, "MimeType");
        if (str != null) m_doc.setMimeType(str);
      } catch (DigiDocException ex) {
        SAXDigiDocException.handleException(ex);
      }
    }
    // <EncryptionMethod>
    if (tName.equals("EncryptionMethod")) {
      checkEncryptedData();
      if (m_tags.search("EncryptedKey") != -1) { // child of <EncryptedKey>
        EncryptedKey ekey = m_doc.getLastEncryptedKey();
        checkEncryptedKey(ekey);
        try {
          ekey.setEncryptionMethod(findAtributeValue(attrs, "Algorithm"));
        } catch (DigiDocException ex) {
          SAXDigiDocException.handleException(ex);
        }
      } else { // child of <EncryptedData>
        try {
          m_doc.setEncryptionMethod(findAtributeValue(attrs, "Algorithm"));
        } catch (DigiDocException ex) {
          SAXDigiDocException.handleException(ex);
        }
      }
    }
    // <EncryptedKey>
    if (tName.equals("EncryptedKey")) {
      checkEncryptedData();
      EncryptedKey ekey = new EncryptedKey();
      m_doc.addEncryptedKey(ekey);
      String str = findAtributeValue(attrs, "Recipient");
      if (str != null) ekey.setRecipient(str);
      str = findAtributeValue(attrs, "Id");
      if (str != null) ekey.setId(str);
    }
    // <EncryptionProperties>
    if (tName.equals("EncryptionProperties")) {
      checkEncryptedData();
      String str = findAtributeValue(attrs, "Id");
      if (str != null) m_doc.setEncryptionPropertiesId(str);
    }
    // <EncryptionProperty>
    if (tName.equals("EncryptionProperty")) {
      checkEncryptedData();
      EncryptionProperty eprop = new EncryptionProperty();
      m_doc.addProperty(eprop);
      String str = findAtributeValue(attrs, "Id");
      if (str != null) eprop.setId(str);
      str = findAtributeValue(attrs, "Target");
      if (str != null) eprop.setTarget(str);
      str = findAtributeValue(attrs, "Name");
      try {
        if (str != null) eprop.setName(str);
      } catch (DigiDocException ex) {
        SAXDigiDocException.handleException(ex);
      }
    }
  }