code: public static String domToString(Node dom, boolean withXmlDeclaration)
              throws Exception {
          Transformer t = XmlTransformUtility.getTransformer();
          t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
          if (withXmlDeclaration) {
              t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
          } else {
              t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
          }
          t.setOutputProperty(OutputKeys.METHOD, "xml");
  
          /* Transformer */
          StringWriter sw = new StringWriter();
          t.transform(new DOMSource(dom), new StreamResult(sw));
  
          return sw.toString();
      }
docs: TODO: Consider optimizing this with ThreadLocal Transformers