code: public void transform(TransformerFactory factory, URL stylesheetUrl, Result result)
              throws IOException {
          try (InputStream xslInputStream = stylesheetUrl.openStream()) {
              factory.newTemplates(new StreamSource(xslInputStream)).newTransformer()
                      .transform(new DOMSource(document()), result);
          } catch (TransformerException e) {
              throw new IOException(e);
          } finally {
              if (builder.getInputStream() != null) {
                  // essential
                  builder.getInputStream().close();
              }
          }
      }
docs: Transform W3C document of the record in the ISO 2709 input stream by an XSL stylesheet.
  
  @param factory the transformer factory
  @param stylesheetUrl the URL of the stylesheet
  @param result the result of the transformation
  @throws IOException if transformation fails