Preloading shared reference documents
An option is available (PRE_EVALUATE_DOC_FUNCTION) to indicate that calls to the
document() functions with constant string arguments should be evaluated when a
query or stylesheet is compiled, rather than at run-time. This option is intended for use when
a reference or lookup document is used by all queries and transformations. Using this option
has a number of effects:
The URI is resolved using the compile-time
URIResolverrather than the run-time
The document is loaded into a document pool held by the Configuration, whose memory is released only when the
Configurationitself ceases to exist.
All queries and transformations using this document share the same copy.
Any updates to the document that occur between compile-time and run-time have no effect.
The option is selected by setting the configuration property PRE_EVALUATE_DOC_FUNCTION. This option is not available from the command line because it has no useful effect with a single-shot compile-and-run interface.
This option has no effect if the URI supplied to the
document() function includes a fragment identifier.
With XSLT 3.0, a similar effect can be achieved by binding the result of the
call to a static global variable. (According to the specification, it is implementation-defined
whether calls to
doc() in static expressions are allowed. In Saxon, they are.)
It is also possible to preload a specific document into the shared document pool from the
Java application by using the call
document() function is called, the shared document
pool is first checked to see if the requested document is already present. The DocumentPool object also has a
discard() method which causes the document to be released from the pool.