DocumentInfo newdoc;
if (source instanceof NodeInfo || source instanceof DOMSource) {
NodeInfo startNode = controller.prepareInputTree(source);
newdoc = startNode.getDocumentRoot();
} else {
Builder b = controller.makeBuilder();
Receiver s = b;
source = AugmentedSource.makeAugmentedSource(source);
((AugmentedSource)source).setStripSpace(Whitespace.XSLT);
if (controller.getExecutable().stripsInputTypeAnnotations()) {
s = controller.getConfiguration().getAnnotationStripper(s);
}
PathMap map = controller.getPathMapForDocumentProjection();
if (map != null) {
PathMap.PathMapRoot pathRoot = map.getRootForDocument(documentKey);
if (pathRoot != null && !pathRoot.isReturnable() && !pathRoot.hasUnknownDependencies()) {
((AugmentedSource)source).addFilter(config.makeDocumentProjector(pathRoot));
}
}
new Sender(b.getPipelineConfiguration()).send(source, s);
newdoc = (DocumentInfo)b.getCurrentRoot();
b.reset();
if (source instanceof AugmentedSource && ((AugmentedSource)source).isPleaseCloseAfterUse()) {
((AugmentedSource)source).close();
}
}
controller.registerDocument(newdoc, documentKey);