code: public Element addDefaultXml(CmsObject cms, I_CmsXmlDocument document, Element root, Locale locale) {
  
          Iterator<I_CmsXmlSchemaType> i = m_typeSequence.iterator();
          int currentPos = 0;
          List<Element> allElements = CmsXmlGenericWrapper.elements(root);
  
          while (i.hasNext()) {
              I_CmsXmlSchemaType type = i.next();
  
              // check how many elements of this type already exist in the XML
              String elementName = type.getName();
              List<Element> elements = CmsXmlGenericWrapper.elements(root, elementName);
  
              currentPos += elements.size();
              for (int j = elements.size(); j < type.getMinOccurs(); j++) {
                  // append the missing elements
                  Element typeElement = type.generateXml(cms, document, root, locale);
                  // need to check for default value again because the of appinfo "mappings" node
                  I_CmsXmlContentValue value = type.createValue(document, typeElement, locale);
                  String defaultValue = document.getHandler().getDefault(cms, value, locale);
                  if (defaultValue != null) {
                      // only if there is a default value available use it to overwrite the initial default
                      value.setStringValue(cms, defaultValue);
                  }
  
                  // re-sort elements as they have been appended to the end of the XML root, not at the correct position
                  typeElement.detach();
                  allElements.add(currentPos, typeElement);
                  currentPos++;
              }
          }
  
          return root;
      }
docs: Adds the missing default XML according to this content definition to the given document element.<p>
  
  In case the root element already contains sub nodes, only missing sub nodes are added.<p>
  
  @param cms the current users OpenCms context
  @param document the document where the XML is added in (required for default XML generation)
  @param root the root node to add the missing XML for
  @param locale the locale to add the XML for
  
  @return the given root element with the missing content added