net.cfoster.sedna
Interface ModuleManagementService

All Superinterfaces:
Configurable, Service

public interface ModuleManagementService
extends Service

ModuleManagementService allows the Sedna XML:DB user to create, remove and list current XQuery modules within the Sedna XML Database.

Sedna Documentation - XQuery allows putting functions in library modules, so that they can be shared and imported by any query. A library module contains a module declaration followed by variable and/or function declarations. The module declaration specifies its target namespace URI which is used to identify the module in the database. For more information on modules see the XQuery specification.

You can declare XQuery functions in modules and store them in the XML Database under namespace URIs, these functions and variables can be reused over and over in subsequent Queries.

The following code is an example XQuery module:

module namespace math = "http://example.org/math";
declare variable $math:pi as xs:decimal := 3.1415926;

declare function math:increment($num as xs:decimal) as xs:decimal {
    $num + 1
};
declare function math:square($num as xs:decimal) as xs:decimal {
    $num * $num
};

This can be placed into the Sedna XML Database in one of two ways, one method is to build the XQuery module statement in a String.

ModuleManagementService mms = (ModuleManagementService)collection.getService("ModuleManagementService","1.0");
String xqModule = "module namespace math = \"http://example.org/math\"; etc etc....";
mms.storeModule(xqModule);

Another method is to say take it from a InputStream source, e.g. a predefined file.

ModuleManagementService mms = (ModuleManagementService)collection.getService("ModuleManagementService","1.0");
FileInputStream in = new FileInputStream("math.xqlib");
mms.storeModule(in);
in.close();

This interface class is proprietary to the Sedna XML:DB API and is not part of the original XML:DB specification.

Since:
Sedna XML:DB 1.2

Field Summary
static java.lang.String SERVICE_NAME
           
 
Method Summary
 java.lang.String[] listModules()
          Retrieve a list of current XQuery modules held within the database.
 void removeModule(java.lang.String namespaceURI)
          Remove a XQuery module from the database which has the namespace URI of the namespaceURI argument.
 void storeModule(java.io.InputStream moduleStmt)
          Store a XQuery module in the Database, a XQuery module can hold multiple variables and functions which can be imported and used in any subsequent XQueries.
 void storeModule(java.lang.String moduleStmt)
          Store a XQuery module in the Database, a XQuery module can hold multiple variables and functions which can be imported and used in any subsequent XQueries.
 
Methods inherited from interface org.xmldb.api.base.Service
getName, getVersion, setCollection
 
Methods inherited from interface org.xmldb.api.base.Configurable
getProperty, setProperty
 

Field Detail

SERVICE_NAME

static final java.lang.String SERVICE_NAME
See Also:
Constant Field Values
Method Detail

storeModule

void storeModule(java.io.InputStream moduleStmt)
                 throws XMLDBException
Store a XQuery module in the Database, a XQuery module can hold multiple variables and functions which can be imported and used in any subsequent XQueries.

Parameters:
moduleStmt - is an InputStream which when read fully conatins the XQuery Module Statement Definition.
Throws:
XMLDBException
Since:
Sedna XML:DB 1.2

storeModule

void storeModule(java.lang.String moduleStmt)
                 throws XMLDBException
Store a XQuery module in the Database, a XQuery module can hold multiple variables and functions which can be imported and used in any subsequent XQueries.

Parameters:
moduleStmt - is a String which conatins the XQuery Module Statement Definition.
Throws:
XMLDBException
Since:
Sedna XML:DB 1.2

removeModule

void removeModule(java.lang.String namespaceURI)
                  throws XMLDBException
Remove a XQuery module from the database which has the namespace URI of the namespaceURI argument.

Parameters:
namespaceURI - is the namespace URI of the module to be deleted.
Throws:
XMLDBException
Since:
Sedna XML:DB 1.2

listModules

java.lang.String[] listModules()
                               throws XMLDBException
Retrieve a list of current XQuery modules held within the database.

Returns:
a String[] containing namespace URIs of all XQuery modules held within the database.
Throws:
XMLDBException
Since:
Sedna XML:DB 1.2