code: public static InputSource toInputSource(Source s, TransformerFactory fac) {
          try {
              InputSource is = SAXSource.sourceToInputSource(s);
              if (is == null) {
                  ByteArrayOutputStream bos = new ByteArrayOutputStream();
                  StreamResult r = new StreamResult(bos);
                  if (fac == null) {
                      fac = TransformerFactoryConfigurer.NoExternalAccess.configure(TransformerFactory.newInstance());
                  }
                  Transformer t = fac.newTransformer();
                  t.transform(s, r);
                  s = new StreamSource(new ByteArrayInputStream(bos
                                                                .toByteArray()));
                  is = SAXSource.sourceToInputSource(s);
              }
              return is;
          } catch (javax.xml.transform.TransformerConfigurationException e) {
              throw new ConfigurationException(e);
          } catch (javax.xml.transform.TransformerException e) {
              throw new XMLUnitException(e);
          }
      }
docs: Creates a SAX InputSource from a TraX Source.
  
  <p>May use an XSLT identity transformation if SAXSource cannot
  convert it directly.</p>
  
  @param s the source to convert
  @param fac the TransformerFactory to use, will use the defaul
  factory if the value is null.