if (node.getNodeKind() != XdmNodeKind.DOCUMENT) {
// Make a document for this node...is this the right thing to do?
TreeWriter treeWriter = new TreeWriter(runtime);
treeWriter.startDocument(step.getNode().getBaseURI());
treeWriter.addSubtree(node);
treeWriter.endDocument();
node = treeWriter.getResult();
}
result.write(node);
}