docs: public static Element generateXml(CmsModule module, XmlWriteMode writeMode) {
  
          Document doc = DocumentHelper.createDocument();
  
          Element moduleElement = doc.addElement(N_MODULE);
  
          moduleElement.addElement(N_NAME).setText(module.getName());
          if (!module.getName().equals(module.getNiceName())) {
              moduleElement.addElement(N_NICENAME).addCDATA(module.getNiceName());
          } else {
              moduleElement.addElement(N_NICENAME);
          }
          if (CmsStringUtil.isNotEmpty(module.getGroup())) {
              moduleElement.addElement(N_GROUP).setText(module.getGroup());
          }
          if (CmsStringUtil.isNotEmpty(module.getActionClass())) {
              moduleElement.addElement(N_CLASS).setText(module.getActionClass());
          } else {
              moduleElement.addElement(N_CLASS);
          }
  
          String importScript = module.getImportScript();
          if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(importScript)) {
              moduleElement.addElement(N_IMPORT_SCRIPT).addCDATA(importScript);
          }
  
          String site = module.getSite();
          boolean isImportSite = module.hasImportSite();
  
          if (!CmsStringUtil.isEmptyOrWhitespaceOnly(site)) {
              moduleElement.addElement(isImportSite ? N_IMPORT_SITE : N_SITE).setText(site);
          }
  
          moduleElement.addElement(N_EXPORT_MODE).addAttribute(A_NAME, module.getExportMode().toString());
  
          if (CmsStringUtil.isNotEmpty(module.getDescription())) {
              moduleElement.addElement(N_DESCRIPTION).addCDATA(module.getDescription());
          } else {
              moduleElement.addElement(N_DESCRIPTION);
          }
          moduleElement.addElement(N_VERSION).setText(module.getVersion().toString());
          if (module.isAutoIncrement()) {
              moduleElement.addElement(N_AUTOINCREMENT).setText(Boolean.TRUE.toString());
          }
          if ((module.getCheckpointTime() != 0) && (writeMode == XmlWriteMode.config)) {
              moduleElement.addElement(N_CHECKPOINT_TIME).setText("" + module.getCheckpointTime());
          }
  
          if (CmsStringUtil.isNotEmpty(module.getAuthorName())) {
              moduleElement.addElement(N_AUTHORNAME).addCDATA(module.getAuthorName());
          } else {
              moduleElement.addElement(N_AUTHORNAME);
          }
          if (CmsStringUtil.isNotEmpty(module.getAuthorEmail())) {
              moduleElement.addElement(N_AUTHOREMAIL).addCDATA(module.getAuthorEmail());
          } else {
              moduleElement.addElement(N_AUTHOREMAIL);
          }
          if (module.getDateCreated() != CmsModule.DEFAULT_DATE) {
              moduleElement.addElement(N_DATECREATED).setText(CmsDateUtil.getHeaderDate(module.getDateCreated()));
          } else {
              moduleElement.addElement(N_DATECREATED);
          }
  
          if (!module.isReducedExportMode() && CmsStringUtil.isNotEmpty(module.getUserInstalled())) {
              moduleElement.addElement(N_USERINSTALLED).setText(module.getUserInstalled());
          } else {
              moduleElement.addElement(N_USERINSTALLED);
          }
          if (!module.isReducedExportMode() && (module.getDateInstalled() != CmsModule.DEFAULT_DATE)) {
              moduleElement.addElement(N_DATEINSTALLED).setText(CmsDateUtil.getHeaderDate(module.getDateInstalled()));
          } else {
              moduleElement.addElement(N_DATEINSTALLED);
          }
          Element dependenciesElement = moduleElement.addElement(N_DEPENDENCIES);
          for (int i = 0; i < module.getDependencies().size(); i++) {
              CmsModuleDependency dependency = module.getDependencies().get(i);
              dependenciesElement.addElement(N_DEPENDENCY).addAttribute(
                  I_CmsXmlConfiguration.A_NAME,
                  dependency.getName()).addAttribute(A_VERSION, dependency.getVersion().toString());
          }
          Element exportpointsElement = moduleElement.addElement(I_CmsXmlConfiguration.N_EXPORTPOINTS);
          for (int i = 0; i < module.getExportPoints().size(); i++) {
              CmsExportPoint point = module.getExportPoints().get(i);
              exportpointsElement.addElement(I_CmsXmlConfiguration.N_EXPORTPOINT).addAttribute(
                  I_CmsXmlConfiguration.A_URI,
                  point.getUri()).addAttribute(I_CmsXmlConfiguration.A_DESTINATION, point.getConfiguredDestination());
          }
          Element resourcesElement = moduleElement.addElement(N_RESOURCES);
          for (int i = 0; i < module.getResources().size(); i++) {
              String resource = module.getResources().get(i);
              resourcesElement.addElement(I_CmsXmlConfiguration.N_RESOURCE).addAttribute(
                  I_CmsXmlConfiguration.A_URI,
                  resource);
          }
          Element excludeResourcesElement = moduleElement.addElement(N_EXCLUDERESOURCES);
          for (String resource : module.getExcludeResources()) {
              excludeResourcesElement.addElement(I_CmsXmlConfiguration.N_RESOURCE).addAttribute(
                  I_CmsXmlConfiguration.A_URI,
                  resource);
          }
          Element parametersElement = moduleElement.addElement(N_PARAMETERS);
          SortedMap<String, String> parameters = module.getParameters();
          if (parameters != null) {
              List<String> names = new ArrayList<String>(parameters.keySet());
              Collections.sort(names);
              for (String name : names) {
                  String value = parameters.get(name).toString();
                  Element paramNode = parametersElement.addElement(I_CmsXmlConfiguration.N_PARAM);
                  paramNode.addAttribute(I_CmsXmlConfiguration.A_NAME, name);
                  paramNode.addText(value);
              }
          }
  
          // add resource types
          List<I_CmsResourceType> resourceTypes = module.getResourceTypes();
          if (resourceTypes.size() > 0) {
              Element resourcetypesElement = moduleElement.addElement(CmsVfsConfiguration.N_RESOURCETYPES);
              CmsVfsConfiguration.generateResourceTypeXml(resourcetypesElement, resourceTypes, true);
          }
  
          List<CmsExplorerTypeSettings> explorerTypes = module.getExplorerTypes();
          if (explorerTypes.size() > 0) {
              Element explorerTypesElement = moduleElement.addElement(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
              CmsWorkplaceConfiguration.generateExplorerTypesXml(explorerTypesElement, explorerTypes, true);
          }
  
          // return the modules node
          moduleElement.detach();
          return moduleElement;
      }