code: private static org.w3c.dom.Document toDom(final Document doc) {
          try {
              val xmlOutputter = new XMLOutputter();
              val elemStrWriter = new StringWriter();
              xmlOutputter.output(doc, elemStrWriter);
              val xmlBytes = elemStrWriter.toString().getBytes(Charset.defaultCharset());
              val dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);
              dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
              dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
              dbf.setFeature("http://apache.org/xml/features/validation/schema/normalized-value", false);
              dbf.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
              dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
              dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
  
              return dbf.newDocumentBuilder().parse(new ByteArrayInputStream(xmlBytes));
          } catch (final Exception e) {
              LOGGER.trace(e.getMessage(), e);
              return null;
          }
      }
docs: Convert the received jdom doc to a Document element.
  
  @param doc the doc
  @return the org.w3c.dom. document