SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
Using XSLT 2.0
Using XQuery
Handling Source Documents
| Handling Source Documents
| Source Documents on the Command Line
| Collections
| Building a Source Document from an application
» | Preloading shared reference documents
| Writing input filters
| XInclude processing
| Saxon and XML 1.1
| JAXP Source Types
| Third-party Object Models: DOM, JDOM, XOM, and DOM4J
| Choosing a Tree Model
| The PTree File Format
| Validation of Source Documents
| Whitespace Stripping in Source Documents
| Streaming of Large Documents
| Document Projection
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# Preloading shared reference documents

An option is available in the `Configuration` to indicate that calls to the `doc()` or `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:

1. The URI is resolved using the compile-time URIResolver rather than the run-time URIResolver

2. The document is loaded into a document pool held by the `Configuration`, whose memory is released only when the `Configuration` itself ceases to exist;

3. all queries and transformations using this document share the same copy;

4. any updates to the document that occur between compile-time and run-time have no effect.

The option is selected by using `Configuration.setConfigurationProperty()`\ or `TransformerFactory.setAttribute()` with the property name `FeatureKeys.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 `doc()` or `document()` function includes a fragment identifier.

It is also possible to preload a specific document into the shared document pool from the Java application by using the call `config.getDocumentPool().add(doc, uri)`. When the `doc()` or `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.

Next