com.xml_project.morganaxproc.connectors
Class XQueryConnector

java.lang.Object
  extended by com.xml_project.morganaxproc.connectors.XQueryConnector

public abstract class XQueryConnector
extends java.lang.Object

This class defines an interface for the use of XQuery processors with MorganaXProc. It allows you to use any XQuery processor you like in 'p:xquery' by just wrapping an XQueryConnector around it.

The interface to XQuery processors comes in two classes:


Constructor Summary
XQueryConnector()
           
 
Method Summary
abstract  void addXPathFunction(XPathFunction function)
          Adds an user written XPath extension function to the list of visible functions in XQuery
abstract  XQueryExpression compile(java.lang.String query, java.net.URI theURI, java.lang.String version)
          Compiles an XQuery expression into an executable form.
abstract  nu.xom.Document getErrorDocument()
          Return an xom document with the static and dynamic errors occurred while compiling the XQuery expression.
abstract  java.lang.String getInfoString()
          Defines an string displayed on the standard output stream the first time, an instance of the connector is generated.
abstract  boolean implementsVersion(java.lang.String version)
          Checks whether the XQuery processor used in this connector supports a specific version of XQuery.
static XQueryConnector newInstance(java.lang.String className, java.io.PrintWriter infoWriter, java.io.PrintStream messageStream)
          Creates a new instance of an XQueryConnector using the class the given class name.
static XQueryConnector newInstance(XProcConfiguration config, java.io.PrintWriter infoWriter, java.io.PrintStream messageStream)
          Creates a new instance of an XQueryConnector using the class defined in XProcConfiguration.
abstract  void setModuleURIResolver(ModuleURIResolver resolver)
          Sets the resolver for module import.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XQueryConnector

public XQueryConnector()
Method Detail

getInfoString

public abstract java.lang.String getInfoString()
Defines an string displayed on the standard output stream the first time, an instance of the connector is generated. This method should be used to return copyright information of the used XQuery processor.

Returns:
a string identifying the used XQuery processor for the user including copyright information.

implementsVersion

public abstract boolean implementsVersion(java.lang.String version)
Checks whether the XQuery processor used in this connector supports a specific version of XQuery. The requested version is given as a string in the form "1.0".

Parameters:
version - the requested version
Returns:
true if this version is supported, otherwise false

getErrorDocument

public abstract nu.xom.Document getErrorDocument()
Return an xom document with the static and dynamic errors occurred while compiling the XQuery expression. This method is only called if compile returns null to flag errors while compiling the expression. The behaviour in case of a successful compilation is not defined.

Returns:
an xom document containing the errors occurred during compilation.

setModuleURIResolver

public abstract void setModuleURIResolver(ModuleURIResolver resolver)
Sets the resolver for module import.

Parameters:
resolver - the resolver to be used.

addXPathFunction

public abstract void addXPathFunction(XPathFunction function)
                               throws XPathException
Adds an user written XPath extension function to the list of visible functions in XQuery

Parameters:
function - the function to add.
Throws:
XPathException - if the function cannot be casted.

compile

public abstract XQueryExpression compile(java.lang.String query,
                                         java.net.URI theURI,
                                         java.lang.String version)
Compiles an XQuery expression into an executable form.

Parameters:
query - the XQuery expression
theURI - the baseURI to use for compiling the XQuery expression.
version - the version to use or null for the processors default version
Returns:
an XQueryExpression if compilation succeeded or null, if an error occurred.

newInstance

public static final XQueryConnector newInstance(XProcConfiguration config,
                                                java.io.PrintWriter infoWriter,
                                                java.io.PrintStream messageStream)
                                         throws XQueryConnectorException
Creates a new instance of an XQueryConnector using the class defined in XProcConfiguration. This method is called before the execution of the pipeline by MorganaXProc.

Parameters:
config - the XProcConfiguration to use.
infoWriter - the PrintWriter for messages or null.
messageStream - the PrintStream for copyright messages.
Returns:
the newly created XQueryConnector.
Throws:
XQueryConnectorException - if any exception occurs in creating the new XQueryConnector.

newInstance

public static final XQueryConnector newInstance(java.lang.String className,
                                                java.io.PrintWriter infoWriter,
                                                java.io.PrintStream messageStream)
                                         throws XQueryConnectorException
Creates a new instance of an XQueryConnector using the class the given class name. This method is called before the execution of the pipeline by MorganaXProc.

Parameters:
className - A class name for the XQueryConnector to create.
infoWriter - the PrintWriter for messages or null.
messageStream - the PrintStream for copyright messages.
Returns:
the newly created XQueryConnector.
Throws:
XQueryConnectorException - if any exception occurs in creating the new XQueryConnector.