Compile in memory during the execution of a XSQL-Script the defined function and catalog it in the map of functions availables to be used from the program. Allows to:

  • Patch a function using the overwrite='true' attribute to overwrite it.
  • Declare a function in runtime for a concrete case, being careful to use the overwrite='true' attribute so that every time it is executed it is redeclared.
  • Have a set of function in the wic_conf which will be declared during the start of the system and they will be available for all the XSQL-Script programs.


The declaration of functions to overwrite the already existing functions of the system should be used with extreme caution to avoid problems in the execution of the programs.


1 function.declare

    <value /> *


Function '" + name + "' is already defined

A function registered with the indicated name already exists. If you want to overwrite the function, you should use [overwrite='true'].

Compile error

If there is a compile error, it will show an exception with the cause of the error.


It is necessary to use 'overwrite=true' when the function overwriten any already existing or it can be declared more than once due to the fact that during the execution it is declared more than once.

To obtain the compile process log is necessary to activate the flag [verbose='true'] and it will issue messages in the console or in the catalina.out file.


Compile and declare a new class to perform the multiplication between 2 numbers.

<xsql-script name='function_declare_multiply'>
    <function.declare name='multiply' verbose='true'>
public final class multiply extends XSQLScriptFunction
  private final static String[] ATTRIBUTES = null ;
  private final static Class<?>[] ARGUMENTS = new Class[] { Number.class, Number.class };

  protected final boolean isTerminal() { return false; }
  protected final String[] getAttributes() { return ATTRIBUTES; }
  protected final Class<?>[] getArguments() { return ARGUMENTS; }

  protected final Double process(XSQLScriptRunner program, Element el, int deep)
    throws Exception
    Object[] data = getArguments(program, el, deep, ARGUMENTS);
    Number n1 = (Number)data[0];
    Number n2 = (Number)data[1];

    return n1.doubleValue() * n2.doubleValue();

      Multiply = <multiply><number>10</number><number>20</number></multiply>