Running the following code with Saxon 7.8, the output stream under the StreamResult is not properly closed.  And result.getOutputStream() returns null, so I have no way to close the stream from this side.
 
For now, the work-around is to construct the FileOutputStream myself, pass it to the ResultStream constructor, and then directly close the stream.
 
The stream is closed properly with Saxon 7.4.
 
(I'm running WinXP, Java 1.4.1_02)
 
  Thanks,
- Chip Whitmer
  cwhitmer@prism.net
 
**********
import java.io.*;
 
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
 
public class SaxonBug
{
 public static void main( String[] args )
     throws TransformerException
 {
  if( args.length != 3 )
  {
   System.out.println( "Usage: com.mpi.SaxonBug <sourceFile> <resultFile> <xslFile>" );
   return;
  }
 
  File sourceFile = new File( args[0] );
  File resultFile = new File( args[1] );
  File xslFile    = new File( args[2] );
 
  StreamSource source = new StreamSource( sourceFile );
  StreamResult result = new StreamResult( resultFile );
  StreamSource xsl    = new StreamSource( xslFile );
 
  Transformer transformer = new net.sf.saxon.TransformerFactoryImpl().newTransformer( xsl );
 
  transformer.transform( source, result );
 
  if( result.getOutputStream() == null )
  {
   System.out.println( "result.getOutputStream() is null" );
  }
 
  if( resultFile.exists() && !resultFile.delete() )
  {
   System.out.println( "ERROR: File is still open: " + resultFile );
  }
 }
}