code: public static String transform(Source xml, Source xslt)
      {
          if (xml != null && xslt != null) {
              try {
                  StringWriter output = new StringWriter();
                  Result result = new StreamResult(output);
                  javax.xml.transform.TransformerFactory.newInstance().newTransformer(xslt).transform(xml, result);
                  return output.toString();
              } catch (Exception ex) {
                  LOGGER.warn("Failed to apply XSLT transformation: [{}]", ex.getMessage());
              }
          }
          return null;
      }
docs: Apply an XSLT transformation to a Document.
  
  @param xml the document to transform
  @param xslt the stylesheet to apply
  @return the transformation result, or {@code null} if an error occurs or {@code null} xml or xslt input