/**
   * Generates the xml representation and mount in rootNode the structure to be included. Fills the
   * XMLNode structure with the form representation and returns the string.
   */
  public String generateFormXML(Form form, XMLNode rootNode) throws Exception {
    rootNode.addAttribute(ATTR_ID, form.getId().toString());

    addXMLNode("subject", form.getSubject(), rootNode);
    addXMLNode("name", form.getName(), rootNode);
    addXMLNode("displayMode", form.getDisplayMode(), rootNode);
    addXMLNode("labelMode", form.getLabelMode(), rootNode);
    addXMLNode("showMode", form.getShowMode(), rootNode);
    addXMLNode(
        "status", (form.getStatus() != null ? String.valueOf(form.getStatus()) : null), rootNode);
    addXMLNode("formTemplate", form.getFormTemplate(), rootNode);

    for (Field field : form.getFormFields()) {
      generateFieldXML(field, rootNode);
    }

    for (DataHolder dataHolder : form.getHolders()) {
      generateDataHolderXML(dataHolder, rootNode);
    }

    StringWriter sw = new StringWriter();
    rootNode.writeXML(sw, true);

    return sw.toString();
  }
  @Override
  public String generateHeaderFormFormId(long formId) throws IOException {
    XMLNode rootNode = new XMLNode(NODE_FORM, null);
    rootNode.addAttribute(ATTR_ID, String.valueOf(formId));
    StringWriter sw = new StringWriter();
    rootNode.writeXML(sw, true);

    return sw.toString().replace("/", "").trim();
  }