code: private static Source stylesheet(final TransformerFactory factory,
          final Source xml) throws TransformerConfigurationException {
          final Source stylesheet = factory.getAssociatedStylesheet(
              xml, null, null, null
          );
          if (stylesheet == null) {
              throw new IllegalArgumentException(
                  "no associated stylesheet found in XML"
              );
          }
          return stylesheet;
      }
docs: Retrieve a stylesheet from this XML (throws an exception if
  no stylesheet is attached).
  @param factory Transformer factory
  @param xml The XML
  @return Stylesheet found
  @throws TransformerConfigurationException If fails