When a directory contains just one file,
it is not processed. An error message is returned
"Output is a directory, but input is not"
which simply is not true.
I have studied the source code of net.sf.saxon.
Transform and there is a problem on this line:
wholeDirectory = sources.size() > 1;
This is a mistake. You should better checking
the existence of directory (as you do with the
output directory) using File.isDirectory() method.