code: protected static void validateAttributesExists(
          Element element,
          String[] requiredAttributes,
          String[] optionalAttributes)
      throws CmsXmlException {
  
          if (element.attributeCount() < requiredAttributes.length) {
              throw new CmsXmlException(
                  Messages.get().container(
                      Messages.ERR_EL_ATTRIBUTE_TOOFEW_3,
                      element.getUniquePath(),
                      new Integer(requiredAttributes.length),
                      new Integer(element.attributeCount())));
          }
  
          if (element.attributeCount() > (requiredAttributes.length + optionalAttributes.length)) {
              throw new CmsXmlException(
                  Messages.get().container(
                      Messages.ERR_EL_ATTRIBUTE_TOOMANY_3,
                      element.getUniquePath(),
                      new Integer(requiredAttributes.length + optionalAttributes.length),
                      new Integer(element.attributeCount())));
          }
  
          for (int i = 0; i < requiredAttributes.length; i++) {
              String attributeName = requiredAttributes[i];
              if (element.attribute(attributeName) == null) {
                  throw new CmsXmlException(
                      Messages.get().container(
                          Messages.ERR_EL_MISSING_ATTRIBUTE_2,
                          element.getUniquePath(),
                          attributeName));
              }
          }
  
          List<String> rA = Arrays.asList(requiredAttributes);
          List<String> oA = Arrays.asList(optionalAttributes);
  
          for (int i = 0; i < element.attributes().size(); i++) {
              String attributeName = element.attribute(i).getName();
              if (!rA.contains(attributeName) && !oA.contains(attributeName)) {
                  throw new CmsXmlException(
                      Messages.get().container(
                          Messages.ERR_EL_INVALID_ATTRIBUTE_2,
                          element.getUniquePath(),
                          attributeName));
              }
          }
      }
docs: Validates if a given element has exactly the required attributes set.<p>
  
  @param element the element to validate
  @param requiredAttributes the list of required attributes
  @param optionalAttributes the list of optional attributes
  
  @throws CmsXmlException if the validation fails