com.xml_project.morganaxproc.connectors
Interface XQueryExpression


public interface XQueryExpression

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:


Method Summary
 boolean evaluate(nu.xom.Document context)
          Evaluates the compiled XQuery expression with the given document (the first document in port 'source' of p:xquery) as context item.
 javax.xml.namespace.QName getErrorCode()
           
 nu.xom.Document getErrorDocument()
          Return an xom document with the errors occurred during execution of the XQuery expression.
 nu.xom.Node[] getResult()
          Returns the result of the evaluation of the XQuery expression as an array of nodes.
 void setCollectionURIResolver(CollectionURIResolver resolver)
          Sets the resolver to use in query evaluation for fn:collection
 void setDefaultCollection(nu.xom.Document[] sequence)
          Sets the default collection, i.e. the sequence of documents available on port "source" of p:xquery.
 void setParameter(javax.xml.namespace.QName name, java.lang.String value)
          Sets the parameters on port 'parameters' of p:xquery.
 void setURIResolver(javax.xml.transform.URIResolver resolver)
          Sets the uri resolver to use in query evaluation for fn:doc.
 

Method Detail

setDefaultCollection

void setDefaultCollection(nu.xom.Document[] sequence)
                          throws XPathException
Sets the default collection, i.e. the sequence of documents available on port "source" of p:xquery.

Parameters:
sequence - the default collection for the xquery expression.
Throws:
XPathException - if memory is exceeded.

getErrorCode

javax.xml.namespace.QName getErrorCode()

getErrorDocument

nu.xom.Document getErrorDocument()
Return an xom document with the errors occurred during execution of the XQuery expression. This method is only called, if evaluate returns false. The return value in case of a successful execution of the expression is not defined.

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

setURIResolver

void setURIResolver(javax.xml.transform.URIResolver resolver)
Sets the uri resolver to use in query evaluation for fn:doc.

Parameters:
resolver - the uri resolver to use.

setCollectionURIResolver

void setCollectionURIResolver(CollectionURIResolver resolver)
Sets the resolver to use in query evaluation for fn:collection

Parameters:
resolver - the resolver to use

setParameter

void setParameter(javax.xml.namespace.QName name,
                  java.lang.String value)
Sets the parameters on port 'parameters' of p:xquery.

Parameters:
name - the name of the parameter to set.
value - the value of the parameter to set.

evaluate

boolean evaluate(nu.xom.Document context)
Evaluates the compiled XQuery expression with the given document (the first document in port 'source' of p:xquery) as context item.

Parameters:
context - the context item
Returns:
true if execution was successful, false if an error occurred.

getResult

nu.xom.Node[] getResult()
                        throws XPathException
Returns the result of the evaluation of the XQuery expression as an array of nodes. This method is only called, if evaluate return true. the return value in case of a failed execution of the expression is not defined.

Returns:
the node sequence produced by evaluation the expression.
Throws:
XPathException - if conversion failed.