code: private void performTransform(String xslt, Document document,
                                    Result result)
          throws TransformerException, ConfigurationException, XpathException {
          try {
              StreamSource source = new StreamSource(new StringReader(xslt));
              TransformerFactory tf = XMLUnit.newTransformerFactory();
              ErrorListener el = new ErrorListener() {
                      public void error(TransformerException ex)
                          throws TransformerException {
                          // any error in our simple stylesheet must be fatal
                          throw ex;
                      }
                      public void fatalError(TransformerException ex)
                          throws TransformerException {
                          throw ex;
                      }
                      public void warning(TransformerException ex) {
                          // there shouldn't be any warning
                          ex.printStackTrace();
                      }
                  };
              tf.setErrorListener(el);
              Transformer transformer = tf.newTransformer(source);
              // Issue 1985229 says Xalan-J 2.7.0 may return null for
              // illegal input
              if (transformer == null) {
                  throw new XpathException("failed to obtain an XSLT transformer"
                                           + " for XPath expression.");
              }
              transformer.setErrorListener(el);
              transformer.transform(new DOMSource(document), result);
          } catch (javax.xml.transform.TransformerConfigurationException ex) {
              throw new ConfigurationException(ex);
          }
      }
docs: Perform the actual transformation work required
  @param xslt
  @param document
  @param result
  @throws XpathException
  @throws TransformerException
  @throws ConfigurationException