gnu.xquery.lang

Class XQuery

public class XQuery extends Language

The XQuery language.
Field Summary
static Namespace[]defaultFunctionNamespacePath
static StringDEFAULT_ELEMENT_PREFIX
Pseudo-namespace "prefix" for the default element namespace.
static StringDEFAULT_FUNCTION_PREFIX
Pseudo-namespace "prefix" for the default function namespace.
static EnvironmentextensionsEnvEnv
Environment of pre-defined non-standard Qexo/Kawa functions.
static QuoteExpfalseExp
static ConstantFunction0falseFunction
static XQueryinstance
static NamespacekawaFunctionNamespace
static StringKAWA_FUNCTION_NAMESPACE
static StringLOCAL_NAMESPACE
static intPARSE_WITH_FOCUS
Special parser flag used by evalToFocusProc.
static NamespaceqexoFunctionNamespace
static StringQEXO_FUNCTION_NAMESPACE
static StringSCHEMA_INSTANCE_NAMESPACE
static StringSCHEMA_NAMESPACE
static QuoteExptrueExp
static ConstantFunction0trueFunction
static intVARIADIC_FUNCTION_NAMESPACE
static EnvironmentxqEnvironment
static NamespacexqueryFunctionNamespace
static StringXHTML_NAMESPACE
static StringXQUERY_FUNCTION_NAMESPACE
Constructor Summary
XQuery()
Method Summary
voidapplyWithFocus(Procedure proc, Object item, int position, int size, Consumer out)
Call a procedure with a given focus (context).
ObjectapplyWithFocus(Procedure proc, Object item, int position, int size)
Call a procedure with a given focus (context).
voidapplyWithFocus(Procedure proc, Object values, Consumer out)
Call a procedure with each item in a sequence as the context item.
ObjectapplyWithFocus(Procedure proc, Object values)
Call a procedure with each item in a sequence as the context item.
voidapplyWithFocus$X(Procedure proc, Object values, CallContext ctx)
Call a procedure with each item in a sequence as the context item.
static charasChar(Object x)
static NumericasNumber(Object arg)
voiddefine(String name, Object value)
protected voiddefine_method(String name, String cname, String mname)
ProcedureevalToFocusProc(String expr)
Parse an XQuery expression that is the body of a procedure.
ProcedureevalToFocusProc(Reader in, SourceMessages messages)
Parse an XQuery expression from a Reader that is the body of a procedure.
voidevalWithFocus(Reader in, SourceMessages messages, Object values, Consumer out)
Evaluate an expression with each item in a sequence as the context item.
ObjectevalWithFocus(String expr, Object values)
Evaluate an expression with each item in a sequence as the context item.
ObjectevalWithFocus(String expr, Object item, int position, int size)
Evaluate an expression with a given focus (context).
voidevalWithFocus(Reader in, SourceMessages messages, Object item, int position, int size, Consumer out)
Evaluate an expression with a given focus (context).
voideval_with_focus$X(String expr, Object values, CallContext ctx)
Evaluate an expression with a given focus (context).
voideval_with_focus$X(String expr, Object item, int position, int size, CallContext ctx)
Evaluate an expression with a given focus (context).
StringformatType(Type type)
CompilationgetCompilation(Lexer lexer, SourceMessages messages)
static ObjectgetExternal(Symbol name, Object type)
static XQuerygetInstance()
LexergetLexer(InPort inp, SourceMessages messages)
StringgetName()
intgetNamespaceOf(Declaration decl)
ConsumergetOutputConsumer(Writer out)
ProceduregetPrompter()
static TypegetStandardType(String name)
SymbolgetSymbol(String name)
TypegetTypeFor(String name)
TypegetTypeFor(Class clas)
booleanhasNamespace(Declaration decl, int namespace)
booleanhasSeparateFunctionNamespace()
booleanisTrue(Object value)
static StringmakeClassName(String source)
static Stringmangle(String name)
static intnamespaceForFunctions(int argCount)
booleanparse(Compilation tr, int options)
static voidregisterEnvironment()
The compiler insert calls to this method for applications and applets.
voidresolve(Compilation comp)

Field Detail

defaultFunctionNamespacePath

public static final Namespace[] defaultFunctionNamespacePath

DEFAULT_ELEMENT_PREFIX

public static final String DEFAULT_ELEMENT_PREFIX
Pseudo-namespace "prefix" for the default element namespace.

DEFAULT_FUNCTION_PREFIX

public static final String DEFAULT_FUNCTION_PREFIX
Pseudo-namespace "prefix" for the default function namespace.

extensionsEnvEnv

public static Environment extensionsEnvEnv
Environment of pre-defined non-standard Qexo/Kawa functions.

falseExp

public static QuoteExp falseExp

falseFunction

public static final ConstantFunction0 falseFunction

instance

public static final XQuery instance

kawaFunctionNamespace

public static final Namespace kawaFunctionNamespace

KAWA_FUNCTION_NAMESPACE

public static final String KAWA_FUNCTION_NAMESPACE

LOCAL_NAMESPACE

public static final String LOCAL_NAMESPACE

PARSE_WITH_FOCUS

public static final int PARSE_WITH_FOCUS
Special parser flag used by evalToFocusProc.

qexoFunctionNamespace

public static final Namespace qexoFunctionNamespace

QEXO_FUNCTION_NAMESPACE

public static final String QEXO_FUNCTION_NAMESPACE

SCHEMA_INSTANCE_NAMESPACE

public static final String SCHEMA_INSTANCE_NAMESPACE

SCHEMA_NAMESPACE

public static final String SCHEMA_NAMESPACE

trueExp

public static QuoteExp trueExp

trueFunction

public static final ConstantFunction0 trueFunction

VARIADIC_FUNCTION_NAMESPACE

public static final int VARIADIC_FUNCTION_NAMESPACE

xqEnvironment

public static final Environment xqEnvironment

xqueryFunctionNamespace

public static final Namespace xqueryFunctionNamespace

XHTML_NAMESPACE

public static final String XHTML_NAMESPACE

XQUERY_FUNCTION_NAMESPACE

public static final String XQUERY_FUNCTION_NAMESPACE

Constructor Detail

XQuery

public XQuery()

Method Detail

applyWithFocus

public void applyWithFocus(Procedure proc, Object item, int position, int size, Consumer out)
Call a procedure with a given focus (context).

Parameters: proc a 3-operand Procedure as returned by evalToFocusProc item the context item, passed as the first argument to proc position the context position, passed as the second argument size the context size, passed as the second argument out where to send the result of proc

applyWithFocus

public Object applyWithFocus(Procedure proc, Object item, int position, int size)
Call a procedure with a given focus (context).

Parameters: proc a 3-operand Procedure as returned by evalToFocusProc item the context item, passed as the first argument to proc position the context position, passed as the second argument size the context size, passed as the second argument

Returns: the result of applying proc

applyWithFocus

public void applyWithFocus(Procedure proc, Object values, Consumer out)
Call a procedure with each item in a sequence as the context item.

Parameters: proc a 3-operand Procedure as returned by evalToFocusProc values a sequence. The proc is called once for each item, with the item as the first argument, a 1-based index as the second argument, and the sequence size as the third argument. out where to send the result of proc

applyWithFocus

public Object applyWithFocus(Procedure proc, Object values)
Call a procedure with each item in a sequence as the context item.

Parameters: proc a 3-operand Procedure as returned by evalToFocusProc values a sequence. The proc is called once for each item, with the item as the first argument, a 1-based index as the second argument, and the sequence size as the third argument.

Returns: the result of applying proc

applyWithFocus$X

public void applyWithFocus$X(Procedure proc, Object values, CallContext ctx)
Call a procedure with each item in a sequence as the context item.

Parameters: proc a 3-operand Procedure as returned by evalToFocusProc values a sequence. The proc is called once for each item, with the item as the first argument, a 1-based index as the second argument, and the sequence size as the third argument. ctx the CallContext. The $X in the method name tells Kawa that this argument is implicit when invoked from XQuery.

asChar

public static char asChar(Object x)

asNumber

public static Numeric asNumber(Object arg)

define

public void define(String name, Object value)

define_method

protected void define_method(String name, String cname, String mname)

evalToFocusProc

public Procedure evalToFocusProc(String expr)
Parse an XQuery expression that is the body of a procedure. Helper method used by evalWithFocus methods.

Parameters: expr an XQuery expression (query) to evaluate

Returns: a 3-operand Procedure whose arguments become the context item, position, and size.

evalToFocusProc

public Procedure evalToFocusProc(Reader in, SourceMessages messages)
Parse an XQuery expression from a Reader that is the body of a procedure. Helper method used by evalWithFocus methods.

Parameters: in where we read the expression from messages where to write syntax errors

Returns: a 3-operand Procedure whose arguments become the context item, position, and size.

evalWithFocus

public void evalWithFocus(Reader in, SourceMessages messages, Object values, Consumer out)
Evaluate an expression with each item in a sequence as the context item.

Parameters: in where we read the expression from messages where to write syntax errors values becomes the context sequence while evaluating expr. out where to send the result of the expression

evalWithFocus

public Object evalWithFocus(String expr, Object values)
Evaluate an expression with each item in a sequence as the context item.

Parameters: expr an XQuery expression (query) to evaluate values becomes the context sequence while evaluating the expression

Returns: the result of evaluating the expression

evalWithFocus

public Object evalWithFocus(String expr, Object item, int position, int size)
Evaluate an expression with a given focus (context).

Parameters: expr an XQuery expression (query) to evaluate item becomes the context item while evaluating expr. position becomes the context position size becomes the context size

Returns: the result of evaluating expr

evalWithFocus

public void evalWithFocus(Reader in, SourceMessages messages, Object item, int position, int size, Consumer out)
Evaluate an expression with a given focus (context).

Parameters: in where we read the expression from messages where to write syntax errors item becomes the context item while evaluating the expression position becomes the context position size becomes the context size out where to send the result of the expression

eval_with_focus$X

public void eval_with_focus$X(String expr, Object values, CallContext ctx)
Evaluate an expression with a given focus (context). Similar to evalWithFocus(String, Object, Consumer). The "$X" in the method name tells the Kawa compiler that the CallContext argument is implicit, so it can be invoked from XQuery code thus: XQuery:eval-with-focus($xquery, "expr", $sequence)

eval_with_focus$X

public void eval_with_focus$X(String expr, Object item, int position, int size, CallContext ctx)
Evaluate an expression with a given focus (context). Similar to evalWithFocus(String, Object, int, int, Consumer). The "$X" in the method name tells the Kawa compiler that the CallContext argument is implicit, so it can be invoked from XQuery code thus: XQuery:eval-with-focus($xquery, "expr", $item, $pos, $size)

formatType

public String formatType(Type type)

getCompilation

public Compilation getCompilation(Lexer lexer, SourceMessages messages)

getExternal

public static Object getExternal(Symbol name, Object type)

getInstance

public static XQuery getInstance()

getLexer

public Lexer getLexer(InPort inp, SourceMessages messages)

getName

public String getName()

getNamespaceOf

public int getNamespaceOf(Declaration decl)

getOutputConsumer

public Consumer getOutputConsumer(Writer out)

getPrompter

public Procedure getPrompter()

getStandardType

public static Type getStandardType(String name)

getSymbol

public Symbol getSymbol(String name)

getTypeFor

public Type getTypeFor(String name)

getTypeFor

public Type getTypeFor(Class clas)

hasNamespace

public boolean hasNamespace(Declaration decl, int namespace)

hasSeparateFunctionNamespace

public boolean hasSeparateFunctionNamespace()

isTrue

public boolean isTrue(Object value)

makeClassName

public static String makeClassName(String source)

mangle

public static String mangle(String name)

namespaceForFunctions

public static int namespaceForFunctions(int argCount)

parse

public boolean parse(Compilation tr, int options)

registerEnvironment

public static void registerEnvironment()
The compiler insert calls to this method for applications and applets.

resolve

public void resolve(Compilation comp)