code: private void checkMaxOccurs(List<Element> elements, int maxOccurs, String typeName) {
  
          if (elements.size() > maxOccurs) {
              if (typeName.equals(CmsXmlCategoryValue.TYPE_NAME)) {
                  if (maxOccurs == 1) {
                      Element category = elements.get(0);
                      List<Element> categories = new ArrayList<Element>();
                      for (Element value : elements) {
                          Iterator<Element> itLink = value.elementIterator();
                          while (itLink.hasNext()) {
                              Element link = itLink.next();
                              categories.add((Element)link.clone());
                          }
                      }
                      category.clearContent();
                      for (Element value : categories) {
                          category.add(value);
                      }
                  }
              }
  
              // too many nodes of this type appear according to the current schema definition
              for (int lo = (elements.size() - 1); lo >= maxOccurs; lo--) {
                  elements.remove(lo);
              }
          }
      }
docs: Removes all nodes that exceed newly defined maxOccurs rules from the list of elements.<p>
  
  @param elements the list of elements to check
  @param maxOccurs maximum number of elements allowed
  @param typeName name of the element type