Qizx/open API

net.axyana.qizxopen.xquery
Class XQModuleManager

java.lang.Object
  extended bynet.axyana.qizxopen.xquery.XQModuleManager
All Implemented Interfaces:
javax.xml.transform.ErrorListener

public class XQModuleManager
extends java.lang.Object
implements javax.xml.transform.ErrorListener

Helper class used by a XQuery engine to compile and cache XQuery modules and XSLT stylesheets.

This is part of the "server side", not seen by applications.

This class is a simple implementation that assumes that all modules URIs can be resolved using the same base location (any URL supported by Java). If the physical location ("at") is not specified in the "import module" declaration, then the module URI is used as follows: periods are replaced by '/' and the extension '.xqm' is appended.

For example with a base URL equal to http://myserver.net/xqmodules, the declaration: import module mod1 = "myapp.module1" will resolve the module location as http://myserver.net/xqmodules/myapp/module1.xqm

Ensures that a module is loaded only once for the same query (i.e. two references to a module from the same query must yield the same object). Modules can be shared by several Connections and are thread safe.

The method resolveModuleLocation(java.lang.String, java.lang.String, java.lang.String) can be overriden in a subclass to redefine the way a module URI is resolved.


Field Summary
static java.lang.String XSLT_OUTPUT_FILE
           
 
Constructor Summary
XQModuleManager(java.lang.String baseURI)
          Builds a Module Manager with a base location for resolution of module URIs.
XQModuleManager(java.net.URL baseURL)
          Builds a Module Manager with a base location for resolution of module URIs.
 
Method Summary
 void error(javax.xml.transform.TransformerException exception)
           
 void fatalError(javax.xml.transform.TransformerException exception)
           
 javax.xml.transform.TransformerFactory getXSLTFactory()
          Gets the TransformerFactory used for XSLT transformations.
 net.axyana.qizxopen.xquery.impl.Module loadModule(net.axyana.qizxopen.xquery.impl.Parser caller, java.lang.String uri, java.lang.String location, java.lang.String auxiliaryBase)
          [used internally by the parser.]
 java.net.URL resolveModuleLocation(java.lang.String namespaceURI, java.lang.String physicalURI, java.lang.String auxiliaryBase)
          Overridable method for resolving a module name and location to an actual URL.
 void setBaseURL(java.net.URL baseURL)
           
 void setXSLTFactory(javax.xml.transform.TransformerFactory value)
          Sets the TransformerFactory used for XSLT transformations.
 void unloadAllModules()
          Unloads all modules.
 void warning(javax.xml.transform.TransformerException exception)
           
 IDocument xslTransform(XQNode source, java.lang.String templates, java.util.Properties parameters, java.util.Properties options)
          Runs a XSLT transformation on an element (internal use).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSLT_OUTPUT_FILE

public static final java.lang.String XSLT_OUTPUT_FILE
See Also:
Constant Field Values
Constructor Detail

XQModuleManager

public XQModuleManager(java.net.URL baseURL)
                throws java.io.IOException
Builds a Module Manager with a base location for resolution of module URIs.


XQModuleManager

public XQModuleManager(java.lang.String baseURI)
                throws java.io.IOException
Builds a Module Manager with a base location for resolution of module URIs.

Method Detail

setBaseURL

public void setBaseURL(java.net.URL baseURL)

resolveModuleLocation

public java.net.URL resolveModuleLocation(java.lang.String namespaceURI,
                                          java.lang.String physicalURI,
                                          java.lang.String auxiliaryBase)
                                   throws java.io.IOException
Overridable method for resolving a module name and location to an actual URL. The default method is use the base URL of the module manager and the physical URI of the module (specified by the "at" clause). If the physical URI is absent, it is produced from the namespace URI by replacing '.' by '/' and adding the ".xqm" extension. For example "package1.package2.module1" would be expanded into "<base-url>/package1/package2/module1.xqm"

Throws:
java.io.IOException

unloadAllModules

public void unloadAllModules()
Unloads all modules. Main Queries can still refer safely to the modules.

Note: Due to possible dependencies between modules, it would be very difficult to unload a module selectively.


loadModule

public net.axyana.qizxopen.xquery.impl.Module loadModule(net.axyana.qizxopen.xquery.impl.Parser caller,
                                                         java.lang.String uri,
                                                         java.lang.String location,
                                                         java.lang.String auxiliaryBase)
                                                  throws java.io.IOException,
                                                         XQueryException
[used internally by the parser.]

Throws:
java.io.IOException
XQueryException

setXSLTFactory

public void setXSLTFactory(javax.xml.transform.TransformerFactory value)
Sets the TransformerFactory used for XSLT transformations.


getXSLTFactory

public javax.xml.transform.TransformerFactory getXSLTFactory()
Gets the TransformerFactory used for XSLT transformations. Useful for configuring the default factory.


error

public void error(javax.xml.transform.TransformerException exception)
           throws javax.xml.transform.TransformerException
Specified by:
error in interface javax.xml.transform.ErrorListener
Throws:
javax.xml.transform.TransformerException

fatalError

public void fatalError(javax.xml.transform.TransformerException exception)
                throws javax.xml.transform.TransformerException
Specified by:
fatalError in interface javax.xml.transform.ErrorListener
Throws:
javax.xml.transform.TransformerException

warning

public void warning(javax.xml.transform.TransformerException exception)
Specified by:
warning in interface javax.xml.transform.ErrorListener

xslTransform

public IDocument xslTransform(XQNode source,
                              java.lang.String templates,
                              java.util.Properties parameters,
                              java.util.Properties options)
                       throws javax.xml.transform.TransformerException,
                              XQueryException
Runs a XSLT transformation on an element (internal use).

Parameters:
source - node on which the transformation is applied.
templates - URI of a stylesheet (resolved by the Module Manager).
parameters - a set name/value pairs specifying initial values for global xsl:param in the stylesheet.
options - a set name/value pairs specifying options for the transformation:
  • 'output-file': name of an output file for the transformation; in that case a null tree is returned and a StreamResult is used.
  • standard JAXP "output keys"
  • other options specific to the XSLT engine can be accepted.
Returns:
a Document in memory, or null if the options specify an output file.
Throws:
javax.xml.transform.TransformerException
XQueryException

© 2005 Axyana Software