<?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html> <head> <this-is section="sourcedocs" page="preloading" subpage=""/> <!-- Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Preloading shared reference documents</title> <meta name="coverage" content="Worldwide"/> <meta name="copyright" content="Copyright Saxonica Ltd"/> <meta name="title" content="Saxonica: XSLT and XQuery Processing: Preloading shared reference documents"/> <meta name="robots" content="noindex,nofollow"/> <link rel="stylesheet" href="../saxondocs.css" type="text/css"/> </head> <body class="main"> <h1>Preloading shared reference documents</h1> <p>An option is available in the <a class="bodylink" href="../javadoc/net/sf/saxon/Configuration.html"><code>Configuration</code></a> to indicate that calls to the <code>doc()</code> or <code>document()</code> 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:</p> <ol> <li content="para"> <p>The URI is resolved using the compile-time URIResolver rather than the run-time URIResolver</p> </li> <li content="para"> <p>The document is loaded into a document pool held by the <code>Configuration</code>, whose memory is released only when the <code>Configuration</code> itself ceases to exist;</p> </li> <li content="para"> <p>all queries and transformations using this document share the same copy;</p> </li> <li content="para"> <p>any updates to the document that occur between compile-time and run-time have no effect.</p> </li> </ol> <p>The option is selected by using <code>Configuration.setConfigurationProperty()</code>\ or <code>TransformerFactory.setAttribute()</code> with the property name <a class="bodylink" href="../javadoc/net/sf/saxon/lib/FeatureKeys.html#PRE_EVALUATE_DOC_FUNCTION"><code>FeatureKeys.PRE_EVALUATE_DOC_FUNCTION</code></a>. This option is not available from the command line because it has no useful effect with a single-shot compile-and-run interface.</p> <p>This option has no effect if the URI supplied to the <code>doc()</code> or <code>document()</code> function includes a fragment identifier.</p> <p>It is also possible to preload a specific document into the shared document pool from the Java application by using the call <code>config.getGlobalDocumentPool().add(doc, uri)</code>. When the <code>doc()</code> or <code>document()</code> function is called, the shared document pool is first checked to see if the requested document is already present. The <a class="bodylink" href="../javadoc/net/sf/saxon/om/DocumentPool.html"><code>DocumentPool</code></a> object also has a <code>discard()</code> method which causes the document to be released from the pool.</p> <table width="100%"> <tr> <td> <p align="right"><a class="nav" href="xml-catalogs.xml">Next</a></p> </td> </tr> </table> </body> </html>