//Serialization serial
//wd = new GenericWritableDocument(runtime, null, serial);
GenericWritableDocument wd = new GenericWritableDocument(runtime, null, null, output);
//--where serial is pipeline.getSerialization(port)
ReadablePipe rpipe = pipeline.readFrom("result");
//while...
//try {
wd.write(rpipe.read());
//} catch (SaxonApiException e) {
// TODO Auto-generated catch block