Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > XML applications > Use the XML API to perform operations > Precompile


Precompile in Java

We can use the XCompilationFactory interface and its various compile and load methods to compile an expression, query, or stylesheet in advance. The Java classes can be loaded at execution time, therefore avoiding the cost of compilation in the application run time.


Procedure


Example

The following is a basic example of precompiling an XPath expression.

// Create the factory
XFactory factory = XFactory.newInstance();
        
// Get the compilation factory
XCompilationFactory compileFactory = factory.getCompilationFactory();

// Create the compilation parameters XCompilationParameters params = compileFactory.newCompilationParameters("MyXPath");
params.setPackageName("org.example.myxpath");
         
// Generate the compiled classes
compileFactory.compileXPath("/doc/item[@id > 3000]", params);

Appropriate compile methods are available for XQuery and XSLT as well.
Precompile using the command-line tools
Load a precompiled executable

+

Search Tips   |   Advanced Search