David Carlisle speculated:
It seems to me that the only way an XSLT processor can ensure that
document('foo') always returns the same node set is to hand on to it (either
the node set, or the document) after the first access.
There are two questions here: (a) ensuring that the contents are still the same
if the document is re-read, and (b) ensuring that the same node ids are
generated if the contents are unchanged. You can do (a) by locking the resource
if it happens to be held in a database or a WebDAV server, or you could do it
optimistically by checking the "last-update" timestamp and crashing out if the
document has changed. You can do (b) simply by remembering the
URL-to-document-number mapping, even if you have discarded the contents and
need to refetch and reparse the XML.
Saxon DOES keep the document in memory for the duration of the transformation,
to some people's occasional annoyance; there are circumstances in which I think
this is avoidable.
Michael Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list