saxon:discard-document

Marks a document as being eligible for garbage collection.

discard-document($doc as document-node()) ➔ document-node()

Arguments

 

$doc

document-node()

The document to be dropped from memory

Result

document-node()

Namespace

http://saxon.sf.net/

Notes on the Saxon implementation

Available since Saxon 8.0.

Details

This function removes a document from Saxon's internal document pool. The document remains in memory for the time being, but will be released from memory by the Java garbage collector when all references to nodes in the document tree have gone out of scope. This has the benefit of releasing memory, but the drawback is that if the same document is loaded again during the same transformation, it will be reparsed from the source text, and different node identifiers will be allocated. The function returns the document node that was supplied as an argument, allowing it to be used in a call such as select="saxon:discard-document(document('a.xml'))".

When processing a collection, a useful construct is for-each select="collection(X)!discard-document(.)"...