docs: @SuppressWarnings("unchecked")
      public static CmsXmlPage convertToXmlPage(CmsObject cms, byte[] content, Locale locale, String encoding)
      throws CmsImportExportException, CmsXmlException {
  
          CmsXmlPage xmlPage = null;
  
          Document page = CmsXmlUtils.unmarshalHelper(content, null);
  
          Element xmltemplate = page.getRootElement();
          if ((xmltemplate == null) || !"XMLTEMPLATE".equals(xmltemplate.getName())) {
              throw new CmsImportExportException(Messages.get().container(Messages.ERR_NOT_FOUND_ELEM_XMLTEMPLATE_0));
          }
  
          // get all edittemplate nodes
          Iterator<Element> i = xmltemplate.elementIterator("edittemplate");
          boolean useEditTemplates = true;
          if (!i.hasNext()) {
              // no edittemplate nodes found, get the template nodes
              i = xmltemplate.elementIterator("TEMPLATE");
              useEditTemplates = false;
          }
  
          // now create the XML page
          xmlPage = new CmsXmlPage(locale, encoding);
  
          while (i.hasNext()) {
              Element currentTemplate = i.next();
              String bodyName = currentTemplate.attributeValue("name");
              if (CmsStringUtil.isEmpty(bodyName)) {
                  // no template name found, use the parameter body name
                  bodyName = "body";
              }
              String bodyContent = null;
  
              if (useEditTemplates) {
                  // no content manipulation needed for edittemplates
                  bodyContent = currentTemplate.getText();
              } else {
                  // parse content for TEMPLATEs
                  StringBuffer contentBuffer = new StringBuffer();
                  for (Iterator<Node> k = currentTemplate.nodeIterator(); k.hasNext();) {
                      Node n = k.next();
                      if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
                          contentBuffer.append(n.getText());
                          continue;
                      } else if (n.getNodeType() == Node.ELEMENT_NODE) {
                          if ("LINK".equals(n.getName())) {
                              contentBuffer.append(OpenCms.getSystemInfo().getOpenCmsContext());
                              contentBuffer.append(n.getText());
                              continue;
                          }
                      }
                  }
                  bodyContent = contentBuffer.toString();
              }
  
              if (bodyContent == null) {
                  throw new CmsImportExportException(Messages.get().container(Messages.ERR_BODY_CONTENT_NOT_FOUND_0));
              }
  
              bodyContent = CmsStringUtil.substitute(
                  bodyContent,
                  CmsStringUtil.MACRO_OPENCMS_CONTEXT,
                  OpenCms.getSystemInfo().getOpenCmsContext());
  
              if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(bodyContent)) {
                  xmlPage.addValue(bodyName, locale);
                  xmlPage.setStringValue(cms, bodyName, locale, bodyContent);
              }
          }
  
          return xmlPage;
  
      }