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 ) ; } }
Creates a SAX InputSource from a TraX Source .