Saxon-SA provides an optimization called streaming copy, specifically designed for processing of large documents, where the need to allocate sufficient memory to hold the entire source tree is traditionally a problem. In Saxon 9.1 this becomes available in XQuery as well as XSLT.