oracle.xquery
Class XQueryContext

java.lang.Object
  |
  +--oracle.xquery.XQueryContext

public class XQueryContext
extends java.lang.Object

XQuerycontext - This class provides the context for executing XQueries
This class can be used to create a context from which queries can be run. For instance, we can execute a bunch of function registeration calls and then run a XQuery over it.
This is the main class to be called for executing XQUery

 Example
 
  XQueryContext ctx = new XQueryContext();

   try
   {
     // create a string from the file
     Reader strm = new FileReader("exmpl1.xml");
 
     // prepare the query
     PreparedXQuery xq = ctx.prepareXQuery(strm);
 
     // get a resultset
     XQueryResultSet rset = xq.executeQuery(printPlan);
 
     while (rset.next())
     {
       XMLNode node = rset.getNode();  // get the result nodes
       System.out.println(" NODE "+ node.getNodeName());
       node.print(System.out);
     }
   }
   catch (Exception e)
   {
      // do something.. 
   }
 


Constructor Summary
XQueryContext()
          Constructor for the XQueryContext
XQueryContext(java.sql.Connection conn)
          Constructor for the XQueryContext
XQueryContext(java.sql.Connection conn, java.lang.String baseurl)
          Constructor for the XQueryContext
XQueryContext(java.lang.String baseurl)
          Constructor for the XQueryContext
XQueryContext(XQMesg msg)
          Constructor for the XQueryContext
 
Method Summary
 java.lang.String getBaseUrl()
          Get the baseurl registered with the context
 java.lang.String getXQueryStrFromXQX(java.lang.String xqueryx, PreparedXQuery prepXquery)
           
static void main(java.lang.String[] argv)
           
 PreparedXQuery prepareXQuery(java.io.Reader xquery)
          Prepare a xquery for execution
 PreparedXQuery prepareXQuery(java.lang.String xquery)
          Prepare a xquery for execution
 PreparedXQuery prepareXQueryX(java.io.Reader xqueryx)
          Prepare a xquery for execution (XQueryX)
 PreparedXQuery prepareXQueryX(java.lang.String xqueryx)
          Prepare a xquery for execution (XQueryX)
 void registerDatasource(java.lang.String dsname, XMLDataSource dsimpl)
          Register datasource
 void registerFunction(java.lang.String function)
          Register a function for later evaluation
 void setBaseUrl(java.lang.String baseurl)
          Set the baseurl for the context
 void setConnectionDesc(java.lang.String descname, java.sql.Connection conn)
          Set connection descriptor in the case when multiple connections are required.
 void setDefaultConnection(java.sql.Connection conn)
          Sets the default SQL connection
 void setQueryTransform(oracle.xml.parser.v2.XSLStylesheet xslt)
          Set a XSL-T transform on the XQueryX before execution This can be used for enforcing security (VPD) on the query or for auditing purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XQueryContext

public XQueryContext()
Constructor for the XQueryContext

XQueryContext

public XQueryContext(XQMesg msg)
Constructor for the XQueryContext
Parameters:
msg - Message descriptor (for locale specific messages)

XQueryContext

public XQueryContext(java.sql.Connection conn)
Constructor for the XQueryContext
Parameters:
conn - database connection

XQueryContext

public XQueryContext(java.lang.String baseurl)
Constructor for the XQueryContext
Parameters:
baseurl - = the base url to be used for the file name resolution

XQueryContext

public XQueryContext(java.sql.Connection conn,
                     java.lang.String baseurl)
Constructor for the XQueryContext
Parameters:
conn - - the connection to be used for SQL statements
baseurl - = the base url to be used for the file name resolution
Method Detail

setDefaultConnection

public void setDefaultConnection(java.sql.Connection conn)
Sets the default SQL connection
Parameters:
conn - The SQL connection

setConnectionDesc

public void setConnectionDesc(java.lang.String descname,
                              java.sql.Connection conn)
Set connection descriptor in the case when multiple connections are required. This is useful only if the sql or other clauses which access the database, need to be aware of multiple database connections Otherwise use the XQueryContext(java.sql.Connection) constructor.
Parameters:
descname - The name for the connection
conn - database connection

registerDatasource

public void registerDatasource(java.lang.String dsname,
                               XMLDataSource dsimpl)
Register datasource
Parameters:
dsname - The name for the connection
dsimpl - datasource implementation

prepareXQuery

public PreparedXQuery prepareXQuery(java.lang.String xquery)
                             throws XQException
Prepare a xquery for execution
Parameters:
xquery - - the XQuery string to be executed

prepareXQuery

public PreparedXQuery prepareXQuery(java.io.Reader xquery)
                             throws XQException
Prepare a xquery for execution
Parameters:
xquery - - the XQuery string to be executed

prepareXQueryX

public PreparedXQuery prepareXQueryX(java.lang.String xqueryx)
                              throws XQException
Prepare a xquery for execution (XQueryX)
Parameters:
xqueryx - - the XQueryX string to be executed

prepareXQueryX

public PreparedXQuery prepareXQueryX(java.io.Reader xqueryx)
                              throws XQException
Prepare a xquery for execution (XQueryX)
Parameters:
xqueryx - - the XQueryX string to be executed

setQueryTransform

public void setQueryTransform(oracle.xml.parser.v2.XSLStylesheet xslt)
Set a XSL-T transform on the XQueryX before execution This can be used for enforcing security (VPD) on the query or for auditing purposes. (e.g. how many queries access the foo document)
Parameters:
xslt - - the XSLT to be used

setBaseUrl

public void setBaseUrl(java.lang.String baseurl)
Set the baseurl for the context
Parameters:
baseurl - - the baseuri to be set

getBaseUrl

public java.lang.String getBaseUrl()
Get the baseurl registered with the context
Parameters:
baseurl - - the baseuri to be set

registerFunction

public void registerFunction(java.lang.String function)
                      throws XQException
Register a function for later evaluation
Parameters:
function - - the function to be registered

getXQueryStrFromXQX

public java.lang.String getXQueryStrFromXQX(java.lang.String xqueryx,
                                            PreparedXQuery prepXquery)

main

public static void main(java.lang.String[] argv)