## galapi
Class Galax

    java.lang.Object
      galapi.Galax

public class Galax
extends java.lang.Object

The `Galax` class contains methods needed to perform queries and to manipulate data under different representations.

Constructor Summary
`Galax()`

Method Summary
`static ModuleContext` `addExternalContext(ModuleContext mod_ctxt, ExternalContext ext_ctxt)` Extends the given module context with the external context.
`static ProcessingContext` `defaultProcessingContext()` Returns the default `ProcessingContext` which just contains flags for controlling debugging, printing, and the processing phases.
`static ModuleContext` `evalGlobalVariables(ModuleContext mod_ctxt)` Evaluates the expressions for all - possibly mutually dependent - global variables.
`static ItemList` `evalQueryFunction(ModuleContext c, java.lang.String funname, ItemList[] params)` Given the `ModuleContext`, evaluates the function whose name is given by `funname` applied to the array of `ItemListitem`arguments.``
`static ItemList` `evalStatementFromFileWithContextItemFromXML(Item ctxt, java.lang.String querystr)` Bind the context item (the XPath "." expression) to the XML value in the item list argument and evaluate the XQuery statement in the file with name in the string argument.
`static ItemList` `evalStatementFromString(ModuleContext c, java.lang.String querystring)` Given the `ModuleContext`, evaluates the XQuery statement in the string argument.
`static ItemList` `evalStatements(QueryContext q)` Given the `QueryContext`, evaluates the statements containded in the query.
`static ItemList` `evalStatementWithContextItemFromDocument(java.lang.String filename, java.lang.String querystr)` Bind the context item (the XPath "." expression) to the XML document in the resource named by the first string argument, and evaluate the XQuery statement in the second string argument.
`static ItemList` `evalStatementWithContextItemFromXML(Item ctxt, java.lang.String querystr)` Bind the context item (the XPath "." expression) to the XML value in the item list argument and evaluate the XQuery statement in the string argument.
`static ItemList` `evalStatementWithVariablesFromXML(NameValuePair[] vars, java.lang.String querystr)` The first argument is a list of variable name and XML value pairs.
`static ModuleContext` `importLibraryModule(ModuleContext mod_ctxt, java.lang.String filename)` Used to import other library modules.
`static QueryContext` `importMainModule(ModuleContext mod_ctxt, java.lang.String filename)` Used to import a main module defined in a file.
`protected static int` `importMainModuleFromString(int mod_ctxt, java.lang.String str)`
`static QueryContext` `importMainModuleFromString(ModuleContext mod_ctxt, java.lang.String str)` Same as `importMainModule`, but module definition is provided in a string instead of a file.
`static void` `init()` Does the initialization stuff, that is it passes program arguments to the OCaml Sys module.
`static NodeList` `loadDocument(java.lang.String filename)` Loads an XML document into the Galax data model.
`static NodeList` `loadDocumentValidate(ModuleContext mc, java.lang.String filename)` Loads an XML document and validates it with respect to a `ModuleContext` which may contain imported schemas.
`static ModuleContext` `loadStandardLibrary(ProcessingContext pc)` Load the standard Galax library, which contains the built-in types, namespaces, and functions.
`protected static int` `nativeAddExternalContext(int mod_ctxt, int ext_ctxt)`
`protected static int` `nativeDefaultProcessingContext()`
`protected static int` `nativeEvalGlobalVariables(int mod_ctxt)`
`protected static int` `nativeEvalQueryFunction(int c, java.lang.String funname, int[] params)`
`protected static int` `nativeEvalStatementFromFileWithContextItemFromXML(int it, java.lang.String filename)`
`protected static int` `nativeEvalStatementFromString(int c, java.lang.String querystring)`
`protected static int` `nativeEvalStatements(int q)`
`protected static int` `nativeEvalStatementWithContextItemFromDocument(java.lang.String filename, java.lang.String querystr)`
`protected static int` `nativeEvalStatementWithContextItemFromXML(int it, java.lang.String querystr)`
`protected static int` `nativeEvalStatementWithVariablesFromXML(java.lang.String[] varnames, int[] varvals, java.lang.String querystr)`
`protected static int` `nativeImportLibraryModule(int mod_ctxt, java.lang.String filename)`
`protected static int` `nativeImportMainModule(int mod_ctxt, java.lang.String filename)`
`protected static int` `nativeLoadDocument(java.lang.String filename)`
`protected static int` `nativeLoadDocumentValidate(int mc, java.lang.String filename)`
`protected static int` `nativeLoadStandardLibrary(int pc)`
`protected static void` `nativeSerializeToFile(java.lang.String filename, int xml)`
`protected static void` `nativeSerializeToOutputChannel(int xml)`
`protected static java.lang.String` `nativeSerializeToString(int xml)`
`static void` `serializeToFile(java.lang.String filename, ItemList xml)` Serializes an XQuery data model value to a file
`static void` `serializeToOutputChannel(ItemList xml)` Serializes an XQuery data model value to standard output
`static java.lang.String` `serializeToString(ItemList xml)` Serializes an XQuery data model value to a string

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Galax

    public Galax()

Method Detail

### init

    public static void init()
                     throws GalapiException

  Does the initialization stuff, that is it passes program arguments to the OCaml Sys module.

  Throws:
    `GalapiException`

### loadDocument

    public static NodeList loadDocument(java.lang.String filename)
                                 throws GalapiException

  Loads an XML document into the Galax data model.

  Parameters:
    `filename` - The name of the file containing the XML document
  Returns:
    a list of nodes giving the Galax representation of the document
  Throws:
    `GalapiException`

### loadDocumentValidate

    public static NodeList loadDocumentValidate(ModuleContext mc,
                                                java.lang.String filename)
                                         throws GalapiException

  Loads an XML document and validates it with respect to a `ModuleContext` which may contain imported schemas.

  Parameters:
    `mc` - the context used for validation
    `filename` - the name of the file containing the XML document
  Throws:
    `GalapiException`

### serializeToString

    public static java.lang.String serializeToString(ItemList xml)
                                              throws GalapiException

  Serializes an XQuery data model value to a string

  Parameters:
    `xml` - a collection of items representing an XML value
  Returns:
    a string representation of the collection of items
  Throws:
    `GalapiException`

### serializeToOutputChannel

    public static void serializeToOutputChannel(ItemList xml)
                                         throws GalapiException

  Serializes an XQuery data model value to standard output

  Parameters:
    `xml` - a collection of items representing an XML value
  Throws:
    `GalapiException`

### serializeToFile

    public static void serializeToFile(java.lang.String filename,
                                       ItemList xml)
                                throws GalapiException

  Serializes an XQuery data model value to a file

  Parameters:
    `filename` - the name of the output file to be produced
    `xml` - a collection of items representing an XML value
  Throws:
    `GalapiException`

### defaultProcessingContext

    public static ProcessingContext defaultProcessingContext()
                                                      throws GalapiException

  Returns the default `ProcessingContext` which just contains flags for controlling debugging, printing, and the processing phases.

  Throws:
    `GalapiException`

### loadStandardLibrary

    public static ModuleContext loadStandardLibrary(ProcessingContext pc)
                                             throws GalapiException

  Load the standard Galax library, which contains the built-in types, namespaces, and functions.

  Throws:
    `GalapiException`

### importLibraryModule

    public static ModuleContext importLibraryModule(ModuleContext mod_ctxt,
                                                    java.lang.String filename)
                                             throws GalapiException

  Used to import other library modules.

  Returns:
    the `ModuleContext` argument extended with the module in the string filename argument.
  Throws:
    `GalapiException`

### importMainModule

    public static QueryContext importMainModule(ModuleContext mod_ctxt,
                                                java.lang.String filename)
                                         throws GalapiException

  Used to import a main module defined in a file.

  Returns:
    the `ModuleContext` argument extended with the main module in the string filename argument and a list of statements to evaluate.
  Throws:
    `GalapiException`
  See Also:
    `QueryContext`

### importMainModuleFromString

    public static QueryContext importMainModuleFromString(ModuleContext mod_ctxt,
                                                          java.lang.String str)
                                                   throws GalapiException

  Same as `importMainModule`, but module definition is provided in a string instead of a file.

  Throws:
    `GalapiException`

### addExternalContext

    public static ModuleContext addExternalContext(ModuleContext mod_ctxt,
                                                   ExternalContext ext_ctxt)
                                            throws GalapiException

  Extends the given module context with the external context.

  Parameters:
    `mod_ctxt` - a given `ModuleContext`
    `ext_ctxt` - an `ExternalContext` used for the extension of the context
  Returns:
    a new `ModuleContext` obtained by extending the a given environment with an external environment.
  Throws:
    `GalapiException`

### evalGlobalVariables

    public static ModuleContext evalGlobalVariables(ModuleContext mod_ctxt)
                                             throws GalapiException

  Evaluates the expressions for all - possibly mutually dependent - global variables.

  It must be called before the other evalXXX functions.

  Parameters:
    `mod_ctxt` - a context obtained with one of the methods from this class
  Returns:
    a new context in which the expressions are evaluated
  Throws:
    `GalapiException`

### evalStatementFromString

    public static ItemList evalStatementFromString(ModuleContext c,
                                                   java.lang.String querystring)
                                            throws GalapiException

  Given the `ModuleContext`, evaluates the XQuery statement in the string argument.

  Returns:
    if the statement is an XQuery expression, returns a list of items, otherwise if the statement is an XQuery update, returns an empty list because update statements have side effects on the data model store, but do not return values.
  Throws:
    `GalapiException`

### evalQueryFunction

    public static ItemList evalQueryFunction(ModuleContext c,
                                             java.lang.String funname,
                                             ItemList[] params)
                                      throws GalapiException

  Given the `ModuleContext`, evaluates the function whose name is given by `funname` applied to the array of `ItemListitem`arguments.

  NOTE: Each actual function argument is bound to one item list.

  ``
  Throws:
    `GalapiException`

### evalStatements

    public static ItemList evalStatements(QueryContext q)
                                   throws GalapiException

  Given the `QueryContext`, evaluates the statements containded in the query.

  Returns:
    an XSquery sequence representing the result of this evaluation
  Throws:
    `GalapiException`

### evalStatementWithContextItemFromDocument

    public static ItemList evalStatementWithContextItemFromDocument(java.lang.String filename,
                                                                    java.lang.String querystr)
                                                             throws GalapiException

  Bind the context item (the XPath "." expression) to the XML document in the resource named by the first string argument, and evaluate the XQuery statement in the second string argument.

  Returns:
    the result of evaluating the query in the aforementioned context
  Throws:
    `GalapiException`

### evalStatementWithContextItemFromXML

    public static ItemList evalStatementWithContextItemFromXML(Item ctxt,
                                                               java.lang.String querystr)
                                                        throws GalapiException

  Bind the context item (the XPath "." expression) to the XML value in the item list argument and evaluate the XQuery statement in the string argument.

  Returns:
    the result of evaluating the query in the aforementioned context
  Throws:
    `GalapiException`

### evalStatementFromFileWithContextItemFromXML

    public static ItemList evalStatementFromFileWithContextItemFromXML(Item ctxt,
                                                                       java.lang.String querystr)
                                                                throws GalapiException

  Bind the context item (the XPath "." expression) to the XML value in the item list argument and evaluate the XQuery statement in the file with name in the string argument.

  Returns:
    the result of evaluating the query in the aforementioned context
  Throws:
    `GalapiException`

### evalStatementWithVariablesFromXML

    public static ItemList evalStatementWithVariablesFromXML(NameValuePair[] vars,
                                                             java.lang.String querystr)
                                                      throws GalapiException

  The first argument is a list of variable name and XML value pairs. Bind each variable to the corresponding XML value and evaluate the XQuery statement in the string argument.

  Returns:
    the result of evaluating the query in the aforementioned context
  Throws:
    `GalapiException`

### nativeLoadDocument

    protected static int nativeLoadDocument(java.lang.String filename)

### nativeLoadDocumentValidate

    protected static int nativeLoadDocumentValidate(int mc,
                                                    java.lang.String filename)

### nativeSerializeToString

    protected static java.lang.String nativeSerializeToString(int xml)

### nativeSerializeToOutputChannel

    protected static void nativeSerializeToOutputChannel(int xml)

### nativeSerializeToFile

    protected static void nativeSerializeToFile(java.lang.String filename,
                                                int xml)

### nativeDefaultProcessingContext

    protected static int nativeDefaultProcessingContext()

### nativeLoadStandardLibrary

    protected static int nativeLoadStandardLibrary(int pc)

### nativeImportLibraryModule

    protected static int nativeImportLibraryModule(int mod_ctxt,
                                                   java.lang.String filename)

### nativeImportMainModule

    protected static int nativeImportMainModule(int mod_ctxt,
                                                java.lang.String filename)

### importMainModuleFromString

    protected static int importMainModuleFromString(int mod_ctxt,
                                                    java.lang.String str)

### nativeAddExternalContext

    protected static int nativeAddExternalContext(int mod_ctxt,
                                                  int ext_ctxt)

### nativeEvalGlobalVariables

    protected static int nativeEvalGlobalVariables(int mod_ctxt)

### nativeEvalStatementFromString

    protected static int nativeEvalStatementFromString(int c,
                                                       java.lang.String querystring)

### nativeEvalQueryFunction

    protected static int nativeEvalQueryFunction(int c,
                                                 java.lang.String funname,
                                                 int[] params)

### nativeEvalStatements

    protected static int nativeEvalStatements(int q)

### nativeEvalStatementWithContextItemFromDocument

    protected static int nativeEvalStatementWithContextItemFromDocument(java.lang.String filename,
                                                                        java.lang.String querystr)

### nativeEvalStatementWithContextItemFromXML

    protected static int nativeEvalStatementWithContextItemFromXML(int it,
                                                                   java.lang.String querystr)

### nativeEvalStatementFromFileWithContextItemFromXML

    protected static int nativeEvalStatementFromFileWithContextItemFromXML(int it,
                                                                           java.lang.String filename)

### nativeEvalStatementWithVariablesFromXML

    protected static int nativeEvalStatementWithVariablesFromXML(java.lang.String[] varnames,
                                                                 int[] varvals,
                                                                 java.lang.String querystr)