code: private static Transformer createTransformer(final Source xsltSource) throws Exception {
          final TransformerFactory transformerFactory = TransformerFactory.newInstance();
          Transformer transformer = null;
          if (xsltSource != null) {
              // Create a resolver for imported sheets (assumption: available from classpath or the root of the jar).
              final URIResolver resolver = new URIResolver() {
                  @Override
                  public Source resolve(final String href, final String base) throws TransformerException {
                      return new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(href));
                  }
              };
              transformerFactory.setURIResolver(resolver);
  
              // Transformer using the given sheet.
              transformer = transformerFactory.newTransformer(xsltSource);
              transformer.setURIResolver(resolver);
          } else {
              // Transformer without a sheet, i.e. for "identity transform" (e.g. formatting).
              transformer = transformerFactory.newTransformer();
          }
  
          if (LOGGER.isDebugEnabled()) {
              instrumentTransformer(transformer);
          }
  
          return transformer;
      }
docs: Create a {@link Transformer} from the given sheet.
  
  @param xsltSource
  The sheet to be used for the transformation, or <code>null</code> if an identity transformator is needed.
  @return The created {@link Transformer}
  @throws Exception
  If the creation or instrumentation of the {@link Transformer} runs into trouble.