API

com.ibm.xml.xapi
Interface XStaticContext


public interface XStaticContext

Use the XStaticContext to override prepare time settings. These are settings used when preparing an expression, query or stylesheet. See the XFactory prepare methods and the XCompilationFactory compile methods that take an XStaticContext as an argument. The XFactory class has the method newStaticContext for creating new instances of XStaticContext.

Prepare time settings such as whether to use the interpreter or the compiler, the integer math mode to use, the names and types of external variables and functions, etc. are built directly into the executable and cannot be changed at execution time. Execution-time settings, on the other hand, such as the values of external variables and parameters, and the implementation of external functions are set using the XDynamicContext and may be different for each execution.

Examples of prepare time settings:

Not all settings are applicable for all languages. Refer to the documentation for the individual methods to see which languages the method applies to.

Settings in XStaticContext map to settings in the XPath, XQuery and XSLT static context as defined in the specifications:

See Also:
XFactory, XCompilationFactory, XFactory.newStaticContext(), XDynamicContext

Field Summary
static int BOUNDARY_SPACE_PRESERVE
          The constant indicating the the boundary-space policy for expression evaluation is to preserve white spaces.
static int BOUNDARY_SPACE_STRIP
          The constant indicating the the boundary-space policy for expression evaluation is to strip white spaces
static int CONSTRUCTION_MODE_PRESERVE
          The constant indicating that the type of a constructed element node is xs:anyType, and all attribute and element nodes copied during node construction retain their original types.
static int CONSTRUCTION_MODE_STRIP
          The constant indicating that the type of a constructed element node is xs:untyped; all element nodes copied during node construction receive the type xs:untyped, and all attribute nodes copied during node construction receive the type xs:untypedAtomic.
static int COPY_NAMESPACES_MODE_INHERIT
          The constant indicating that the inherit mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language
static int COPY_NAMESPACES_MODE_NO_INHERIT
          The constant indicating that the no-inherit mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language
static int COPY_NAMESPACES_MODE_NO_PRESERVE
          The constant indicating that the no-preserve mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language
static int COPY_NAMESPACES_MODE_PRESERVE
          The constant indicating that the preserve mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language
static int DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST
          The constant indicating that ordering of empty sequences and NaN values as keys in an order by clause in a FLWOR expression is "greatest".
static int DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST
          The constant indicating that ordering of empty sequences and NaN values as keys in an order by clause in a FLWOR expression is "least".
static int INTEGER_MATH_MODE_ARBITRARY_PRECISION
          The constant indicating that xs:integer values should support an arbitrary number of digits of precision.
static int INTEGER_MATH_MODE_LIMITED_PRECISION
          The constant indicating that xs:integer values need only support the minimum precision required for a minimally conforming processor (18 digits).
static int INTEGER_MATH_MODE_OVERFLOW_DETECTION
          The constant indicating that xs:integer values need only support the minimum precision required for a minimally conforming processor (18 digits) but any overflow condition should be detected and error FOAR0002 raised.
static int ORDERING_MODE_ORDERED
          The constant indicating that ordered results are to be returned by certain path expressions, union, intersect, and except expressions, and FLWOR expressions that have no order by clause.
static int ORDERING_MODE_UNORDERED
          The constant indicating that unordered results are to be returned by certain path expressions, union, intersect, and except expressions, and FLWOR expressions that have no order by clause.
static String UNICODE_CODE_POINT_COLLATION_URI
          Constant definition of the Unicode code point collation URI.
static int XPATH_LATEST_VERSION
          Constant for latest version.
static int XPATH1_0_BC_COMPATIBILITY
          Constant for 1.0 backwards compatibility as defined in the XPath 2.0 specification.
static int XPATH2_0_PURE_COMPATIBILITY
          Constant for pure 2.0 behaviour for XPath (no backwards compatibility).
 
Method Summary
 void declareFunction(QName name, QName type, QName... argTypes)
          Add a function declaration where the return and argument values are single items.
 void declareFunction(QName name, XSequenceType type, XSequenceType... argTypes)
          Add a function declaration where the return and argument values are sequences.
 void declareNamespace(String prefix, String uri)
          Declares a namespace prefix and associates it with a namespace URI.
 void declareVariable(QName name, QName type)
          Add a variable binding to the static context for a single item.
 void declareVariable(QName name, XSequenceType type)
          Add a variable binding to the static context.
 String getBaseURI()
          Get the base URI, if set, otherwise null.
 int getBoundarySpacePolicy()
          Get the boundary-space policy.
 int getConstructionMode()
          Get the construction mode.
 int getCopyNamespacesModeInherit()
          Get the inherit part of the copy-namespaces mode.
 int getCopyNamespacesModePreserve()
          Get the preserve part of the copy-namespaces mode.
 String getDefaultCollation()
          Gets the URI of the default collation.
 String getDefaultCollationForXSLSort()
          Gets the URI of the default collation URI used in an XSLT stylesheet by any xsl:sort element that does not have any collation, lang or case-order attributes, as set by a call to setDefaultCollationForXSLSort(String).
 String getDefaultElementTypeNamespace()
          Gets the URI of the default element/type namespace, or the empty string if not set.
 String getDefaultFunctionNamespace()
          Gets the URI of the default function namespace, or the empty string if not set.
 int getDefaultOrderForEmptySequences()
          Get the default order for empty sequences.
 boolean getFeature(String name)
          Get the state of the named feature.
 XSequenceType[] getFunctionArgTypes(QName name, int arity)
          Get the function argument types.
 XSequenceType getFunctionReturnType(QName name, int arity)
          Get the function return type.
 int getIntegerMathMode()
          Get the integer math mode, which is a constant representing the level of precision required and whether overflow detection is required when working with xs:integer values.
 XMessageHandler getMessageHandler()
          Get the static message handler.
 XModuleResolver getModuleResolver()
          Get the registered resolver for XQuery modules.
 Enumeration<String> getNamespacePrefixes(String namespaceURI)
          Get all prefixes bound to a URI in the current scope.
 String getNamespaceURI(String prefix)
          Retrieves the namespace URI associated with the given prefix.
 int getOrderingMode()
          Get the ordering mode.
 XSourceResolver getSourceResolver()
          Get the registered resolver for source documents.
 boolean getUseCompiler()
          Get the use compiler setting.
 XSequenceType getVariableType(QName name)
          Get the type of a variable binding.
 int getXPathCompatibilityMode()
          Get the XPath 1.0 compatibility mode.
 void setBaseURI(String uri)
          Set the base URI.
 void setBoundarySpacePolicy(int policy)
          Set the boundary-space policy.
 void setConstructionMode(int mode)
          Set the construction mode.
 void setCopyNamespacesModeInherit(int mode)
          Set the inherit part of the copy-namespaces mode.
 void setCopyNamespacesModePreserve(int mode)
          Set the preserve part of the copy namespaces mode.
 void setDefaultCollation(String uri)
          Sets the default collation property of the static context.
 void setDefaultCollationForXSLSort(String uri)
          Sets the collation URI used in an XSLT stylesheet by any xsl:sort element that does not have any collation, lang or case-order attributes.
 void setDefaultElementTypeNamespace(String uri)
          Sets the URI of the default element/type namespace.
 void setDefaultFunctionNamespace(String uri)
          Sets the URI of the default function namespace, the empty string to make it unspecified.
 void setDefaultOrderForEmptySequences(int order)
          Set the default order for empty sequences.
 void setFeature(String name, boolean value)
          Set a feature for this static context.
 void setIntegerMathMode(int mode)
          Set the integer math mode, which is a constant representing the level of precision required and whether overflow detection is required when working with xs:integer values.
 void setMessageHandler(XMessageHandler handler)
          Set a message handler to process static errors and messages.
 void setModuleResolver(XModuleResolver moduleResolver)
          Register a resolver for XQuery modules.
 void setOrderingMode(int mode)
          Set the ordering mode.
 void setSourceResolver(XSourceResolver sourceResolver)
          Register a URI resolver for source documents.
 void setUseCompiler(boolean value)
          Set whether to use the compiler when preparing an expression (as opposed to the interpreter).
 void setXPathCompatibilityMode(int mode)
          Set the XPath 1.0 compatibility mode.
 

Field Detail

BOUNDARY_SPACE_PRESERVE

static final int BOUNDARY_SPACE_PRESERVE
The constant indicating the the boundary-space policy for expression evaluation is to preserve white spaces.

See Also:
setBoundarySpacePolicy(int), Constant Field Values

BOUNDARY_SPACE_STRIP

static final int BOUNDARY_SPACE_STRIP
The constant indicating the the boundary-space policy for expression evaluation is to strip white spaces

See Also:
setBoundarySpacePolicy(int), Constant Field Values

CONSTRUCTION_MODE_PRESERVE

static final int CONSTRUCTION_MODE_PRESERVE
The constant indicating that the type of a constructed element node is xs:anyType, and all attribute and element nodes copied during node construction retain their original types.

See Also:
setConstructionMode(int), Constant Field Values

CONSTRUCTION_MODE_STRIP

static final int CONSTRUCTION_MODE_STRIP
The constant indicating that the type of a constructed element node is xs:untyped; all element nodes copied during node construction receive the type xs:untyped, and all attribute nodes copied during node construction receive the type xs:untypedAtomic.

See Also:
setConstructionMode(int), Constant Field Values

ORDERING_MODE_ORDERED

static final int ORDERING_MODE_ORDERED
The constant indicating that ordered results are to be returned by certain path expressions, union, intersect, and except expressions, and FLWOR expressions that have no order by clause.

See Also:
setOrderingMode(int), Constant Field Values

ORDERING_MODE_UNORDERED

static final int ORDERING_MODE_UNORDERED
The constant indicating that unordered results are to be returned by certain path expressions, union, intersect, and except expressions, and FLWOR expressions that have no order by clause.

See Also:
setOrderingMode(int), Constant Field Values

DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST

static final int DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST
The constant indicating that ordering of empty sequences and NaN values as keys in an order by clause in a FLWOR expression is "greatest". See 3.8.3 Order By and Return Clauses, XQuery 1.0: An XML Query Language for details.

See Also:
setDefaultOrderForEmptySequences(int), Constant Field Values

DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST

static final int DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST
The constant indicating that ordering of empty sequences and NaN values as keys in an order by clause in a FLWOR expression is "least". See 3.8.3 Order By and Return Clauses, XQuery 1.0: An XML Query Language for details.

See Also:
setDefaultOrderForEmptySequences(int), Constant Field Values

COPY_NAMESPACES_MODE_PRESERVE

static final int COPY_NAMESPACES_MODE_PRESERVE
The constant indicating that the preserve mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language

See Also:
setCopyNamespacesModePreserve(int), Constant Field Values

COPY_NAMESPACES_MODE_NO_PRESERVE

static final int COPY_NAMESPACES_MODE_NO_PRESERVE
The constant indicating that the no-preserve mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language

See Also:
setCopyNamespacesModePreserve(int), Constant Field Values

COPY_NAMESPACES_MODE_INHERIT

static final int COPY_NAMESPACES_MODE_INHERIT
The constant indicating that the inherit mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language

See Also:
setCopyNamespacesModeInherit(int), Constant Field Values

COPY_NAMESPACES_MODE_NO_INHERIT

static final int COPY_NAMESPACES_MODE_NO_INHERIT
The constant indicating that the no-inherit mode should be used in namespace binding assignment when an existing element node is copied by an element constructor, as described in 3.7.1 Direct Element Constructors, XQuery 1.0: An XML Query Language

See Also:
setCopyNamespacesModeInherit(int), Constant Field Values

INTEGER_MATH_MODE_LIMITED_PRECISION

static final int INTEGER_MATH_MODE_LIMITED_PRECISION
The constant indicating that xs:integer values need only support the minimum precision required for a minimally conforming processor (18 digits).

See Also:
setIntegerMathMode(int), Constant Field Values

INTEGER_MATH_MODE_ARBITRARY_PRECISION

static final int INTEGER_MATH_MODE_ARBITRARY_PRECISION
The constant indicating that xs:integer values should support an arbitrary number of digits of precision. No overflow should occur.

See Also:
setIntegerMathMode(int), Constant Field Values

INTEGER_MATH_MODE_OVERFLOW_DETECTION

static final int INTEGER_MATH_MODE_OVERFLOW_DETECTION
The constant indicating that xs:integer values need only support the minimum precision required for a minimally conforming processor (18 digits) but any overflow condition should be detected and error FOAR0002 raised.

See Also:
setIntegerMathMode(int), Constant Field Values

XPATH_LATEST_VERSION

static final int XPATH_LATEST_VERSION
Constant for latest version. Currently this is the same as XPATH2_0_PURE_COMPATIBILITY.

See Also:
setXPathCompatibilityMode(int), Constant Field Values

XPATH1_0_BC_COMPATIBILITY

static final int XPATH1_0_BC_COMPATIBILITY
Constant for 1.0 backwards compatibility as defined in the XPath 2.0 specification.

See Also:
setXPathCompatibilityMode(int), Constant Field Values

XPATH2_0_PURE_COMPATIBILITY

static final int XPATH2_0_PURE_COMPATIBILITY
Constant for pure 2.0 behaviour for XPath (no backwards compatibility). This is the default.

See Also:
setXPathCompatibilityMode(int), Constant Field Values

UNICODE_CODE_POINT_COLLATION_URI

static final String UNICODE_CODE_POINT_COLLATION_URI
Constant definition of the Unicode code point collation URI.

See Also:
Constant Field Values
Method Detail

getNamespaceURI

String getNamespaceURI(String prefix)
Retrieves the namespace URI associated with the given prefix.

Parameters:
prefix - The prefix. Cannot be null.
Returns:
The namespace URI, or null if the prefix is unknown.
Throws:
NullPointerException - if prefix is null.

declareNamespace

void declareNamespace(String prefix,
                      String uri)
Declares a namespace prefix and associates it with a namespace URI. If the namespace URI is the empty string, the prefix is removed from the in-scope namespace definitions.

Parameters:
prefix - The prefix. Cannot be null.
uri - The namespace URI. An empty string undeclares the specified prefix. Cannot be null.
Throws:
NullPointerException - if prefix or uri is null.

getDefaultElementTypeNamespace

String getDefaultElementTypeNamespace()
Gets the URI of the default element/type namespace, or the empty string if not set.

This setting does not apply to XSLT which uses the [xsl:]xpath-default-namespace attribute to set the default element/type namespace.

Returns:
The URI of the default element/type namespace, if set, otherwise the empty string.

setDefaultElementTypeNamespace

void setDefaultElementTypeNamespace(String uri)
Sets the URI of the default element/type namespace. Use the empty string to make it unspecified. The default is the empty string.

This setting does not apply to XSLT which uses the [xsl:]xpath-default-namespace attribute to set the default element/type namespace.

Parameters:
uri - The namespace URI of the default element/type namespace, or the empty string to make it unspecified. Cannot be null.
Throws:
NullPointerException - if uri is null.

getDefaultFunctionNamespace

String getDefaultFunctionNamespace()
Gets the URI of the default function namespace, or the empty string if not set.

This setting does not apply to XSLT which uses the standard function namespace defined in Functions and Operators for the default function namespace.

Returns:
The URI of the default function namespace, otherwise the empty string. Cannot be null.

setDefaultFunctionNamespace

void setDefaultFunctionNamespace(String uri)
Sets the URI of the default function namespace, the empty string to make it unspecified. The default is "http://www.w3.org/2005/xpath-functions".

This setting does not apply to XSLT which uses the standard function namespace defined in Functions and Operators for the default function namespace.

Parameters:
uri - The namespace URI of the default function namespace, or the empty string to make it unspecified. Cannot be null.
Throws:
NullPointerException - if uri is null.

getDefaultCollation

String getDefaultCollation()
Gets the URI of the default collation.

Returns:
The URI of the default collation.

setDefaultCollation

void setDefaultCollation(String uri)
Sets the default collation property of the static context. By default, the value is the Unicode codepoint collation URI. The value must not be a relative URI reference.

If a string comparison operation does not specify a collation URI explicitly, and there is no default collation URI explicitly declared in the XSLT stylesheet or XQuery expression that is in scope for the operation, the default collation URI from the XStaticContext is used as the collation URI for the operation.

For an XPath expression, the default collation URI from the XStaticContext is always used as the collation URI for a string comparison operation that does not specify a collation URI explicitly.

Parameters:
uri - The URI reference for the default collation URI
Throws:
NullPointerException - if uri is null
IllegalArgumentException - if uri is a relative URI reference
See Also:
UNICODE_CODE_POINT_COLLATION_URI

getDefaultCollationForXSLSort

String getDefaultCollationForXSLSort()
Gets the URI of the default collation URI used in an XSLT stylesheet by any xsl:sort element that does not have any collation, lang or case-order attributes, as set by a call to setDefaultCollationForXSLSort(String).

Returns:
The URI of the default collation for xsl:sort elements
See Also:
setDefaultCollationForXSLSort(String)

setDefaultCollationForXSLSort

void setDefaultCollationForXSLSort(String uri)
Sets the collation URI used in an XSLT stylesheet by any xsl:sort element that does not have any collation, lang or case-order attributes.

By default, the collation used for such an xsl:sort element is not determined by the default collation property of the static context; instead, unless overridden by a call to this method, the collation selected for such an xsl:sort element is the collation associated with the default Locale as determined by calling java.util.Locale.getDefault()

Parameters:
uri - The URI reference for the default collation URI for xsl:sort. A null reference restores the usual default behaviour
Throws:
IllegalArgumentException - if uri is a relative URI reference

getConstructionMode

int getConstructionMode()
Get the construction mode.

This setting is XQuery specific.

Returns:
The construction mode value. One of: CONSTRUCTION_MODE_PRESERVE, CONSTRUCTION_MODE_STRIP

setConstructionMode

void setConstructionMode(int mode)
Set the construction mode. The default is CONSTRUCTION_MODE_PRESERVE.

This setting is XQuery specific.

Parameters:
mode - The construction mode value. One of: CONSTRUCTION_MODE_PRESERVE, CONSTRUCTION_MODE_STRIP.
Throws:
IllegalArgumentException - if mode is not one of: CONSTRUCTION_MODE_PRESERVE, CONSTRUCTION_MODE_STRIP.

getOrderingMode

int getOrderingMode()
Get the ordering mode.

This setting is XQuery specific.

Returns:
The ordering mode value. One of: ORDERING_MODE_ORDERED, ORDERING_MODE_UNORDERED.

setOrderingMode

void setOrderingMode(int mode)
Set the ordering mode. The default is ORDERING_MODE_ORDERED.

This setting is XQuery specific.

Parameters:
mode - The ordering mode value. One of: ORDERING_MODE_ORDERED, ORDERING_MODE_UNORDERED.
Throws:
IllegalArgumentException - if mode is not one of: ORDERING_MODE_ORDERED, ORDERING_MODE_UNORDERED.

getDefaultOrderForEmptySequences

int getDefaultOrderForEmptySequences()
Get the default order for empty sequences.

This setting is XQuery specific.

Returns:
The default order for empty sequences value. One of: DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST, DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.

setDefaultOrderForEmptySequences

void setDefaultOrderForEmptySequences(int order)
Set the default order for empty sequences. The default is DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.

This setting is XQuery specific.

Parameters:
order - The default order for empty sequences. One of: DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST, DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.
Throws:
IllegalArgumentException - if order is not one of: DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST, DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.

getBoundarySpacePolicy

int getBoundarySpacePolicy()
Get the boundary-space policy.

This setting is XQuery specific.

Returns:
The boundary-space policy value. One of: BOUNDARY_SPACE_PRESERVE, BOUNDARY_SPACE_STRIP.

setBoundarySpacePolicy

void setBoundarySpacePolicy(int policy)
Set the boundary-space policy. The default is BOUNDARY_SPACE_STRIP.

This setting is XQuery specific.

Parameters:
policy - The boundary space policy. One of: BOUNDARY_SPACE_PRESERVE, BOUNDARY_SPACE_STRIP.
Throws:
IllegalArgumentException - if policy is not one of: BOUNDARY_SPACE_PRESERVE, BOUNDARY_SPACE_STRIP.

getCopyNamespacesModePreserve

int getCopyNamespacesModePreserve()
Get the preserve part of the copy-namespaces mode.

This setting is XQuery specific.

Returns:
The copy-namespaces preserve mode value. One of: COPY_NAMESPACES_MODE_PRESERVE, COPY_NAMESPACES_MODE_NO_PRESERVE.

setCopyNamespacesModePreserve

void setCopyNamespacesModePreserve(int mode)
Set the preserve part of the copy namespaces mode. The default is COPY_NAMESPACES_MODE_PRESERVE.

This setting is XQuery specific.

Parameters:
mode - The copy-namespaces preserve mode value. One of: COPY_NAMESPACES_MODE_PRESERVE, COPY_NAMESPACES_MODE_NO_PRESERVE.
Throws:
IllegalArgumentException - if mode is not one of: COPY_NAMESPACES_MODE_PRESERVE, COPY_NAMESPACES_MODE_NO_PRESERVE.

getCopyNamespacesModeInherit

int getCopyNamespacesModeInherit()
Get the inherit part of the copy-namespaces mode.

This setting is XQuery specific.

Returns:
The copy-namespaces inherit mode value. One of: COPY_NAMESPACES_MODE_INHERIT, COPY_NAMESPACES_MODE_NO_INHERIT.

setCopyNamespacesModeInherit

void setCopyNamespacesModeInherit(int mode)
Set the inherit part of the copy-namespaces mode. The default is COPY_NAMESPACES_MODE_INHERIT.

This setting is XQuery specific.

Parameters:
mode - The copy-namespaces inherit mode value. One of: COPY_NAMESPACES_MODE_INHERIT, COPY_NAMESPACES_MODE_NO_INHERIT.
Throws:
IllegalArgumentException - if mode is not one of: COPY_NAMESPACES_MODE_INHERIT, COPY_NAMESPACES_MODE_NO_INHERIT.

getBaseURI

String getBaseURI()
Get the base URI, if set, otherwise null.

Returns:
The base URI, if set, otherwise null.

setBaseURI

void setBaseURI(String uri)
Set the base URI. Pass in null for the uri to restore the default. The default is the base URI of the expression, query, or stylesheet if available. If not available, the current working directory is used.

Parameters:
uri - The new base URI, or null.

getSourceResolver

XSourceResolver getSourceResolver()
Get the registered resolver for source documents.

Returns:
The XSourceResolver if set, otherwise null.

setSourceResolver

void setSourceResolver(XSourceResolver sourceResolver)
Register a URI resolver for source documents. This source resolver only affects documents that are resolved statically such as XSLT imports and includes. Use the XDynamicContext.setSourceResolver method for documents that are resolved dynamically such as for the fn:doc function. Pass in null for the sourceResolver to restore the default source lookup behaviour. The default source resolution behavior is to use the base URI of the expression, query, or stylesheet if available to resolve imports and includes. If the base URI is not available, the current working directory is used.

Parameters:
sourceResolver - The source resolver or null.
See Also:
XSourceResolver

getXPathCompatibilityMode

int getXPathCompatibilityMode()
Get the XPath 1.0 compatibility mode.

Returns:
The XPath compatibility mode, one of: XPATH2_0_PURE_COMPATIBILITY, XPATH1_0_BC_COMPATIBILITY.

setXPathCompatibilityMode

void setXPathCompatibilityMode(int mode)
Set the XPath 1.0 compatibility mode. The default is XPATH2_0_PURE_COMPATIBILITY.

Parameters:
mode - The XPath compatibility mode, one of: XPATH2_0_PURE_COMPATIBILITY, XPATH1_0_BC_COMPATIBILITY, XPATH_LATEST_VERSION.
Throws:
IllegalArgumentException - if mode is not one of: XPATH2_0_PURE_COMPATIBILITY, XPATH1_0_BC_COMPATIBILITY, XPATH_LATEST_VERSION.

getNamespacePrefixes

Enumeration<String> getNamespacePrefixes(String namespaceURI)
Get all prefixes bound to a URI in the current scope.

Parameters:
namespaceURI - URI of namespace to look up.
Returns:
Enumerator for all prefixes bound to namespaceURI in the current scope.

declareFunction

void declareFunction(QName name,
                     QName type,
                     QName... argTypes)
Add a function declaration where the return and argument values are single items. Atomic types (simple types excluding lists and unions) indicate single atomic items. Non-atomic types (complex types, lists, or unions) indicate single elements (not nillable) of the given type. Note that this simply declares the function and a Method object for the function must also be bound to the dynamic context at execution-time. See XDynamicContext.bindFunction(). Predefined QNames for built-in types can be found in XTypeConstants. This method cannot be used to override built-in functions.

Parameters:
name - The name of the function.
type - The return type of the function.
argTypes - The argument types for the function.
Throws:
NullPointerException - if any of name, type, or argTypes is null.
IllegalArgumentException - if the type or any of the argTypes are undefined.
See Also:
XDynamicContext.bindFunction(QName, java.lang.reflect.Method), XDynamicContext.bindFunction(QName, java.lang.reflect.Method, Object), XTypeConstants

declareFunction

void declareFunction(QName name,
                     XSequenceType type,
                     XSequenceType... argTypes)
Add a function declaration where the return and argument values are sequences. Note that this simply declares the function and a Method object for the function must also be bound to the dynamic context. See XDynamicContext.bindFunction(). The XSequenceTypeFactory can be used to create sequence types. This method cannot be used to override built-in functions.

Parameters:
name - The name of the function.
type - the return type of the function.
argTypes - the argument types for the function.
Throws:
NullPointerException - if any of name, type, or argTypes is null.
See Also:
XDynamicContext.bindFunction(QName, java.lang.reflect.Method), XDynamicContext.bindFunction(QName, java.lang.reflect.Method, Object), XSequenceTypeFactory, XFactory.getSequenceTypeFactory()

getFunctionReturnType

XSequenceType getFunctionReturnType(QName name,
                                    int arity)
Get the function return type. This method cannot be used to get the return type of built-in functions.

Parameters:
name - The name of the function.
arity - The arity (number of parameters) of the function.
Returns:
The return type of the function.
Throws:
NullPointerException - if name is null.
IllegalArgumentException - if the arity

getFunctionArgTypes

XSequenceType[] getFunctionArgTypes(QName name,
                                    int arity)
Get the function argument types. This method cannot be used to get the argument types of built-in functions.

Parameters:
name - The name of the Function.
arity - The arity (number of parameters) of the function.
Returns:
The argument types.
Throws:
NullPointerException - if name is null.
IllegalArgumentException - if the arity

declareVariable

void declareVariable(QName name,
                     QName type)
Add a variable binding to the static context for a single item. An atomic type (simple type excluding lists and unions) indicates a single atomic item. A non-atomic type (complex type, list, or union) indicates a single element (not nillable) of the given type. Note that this simply declares the variable, a value must be bound to the XDynamicContext. See the XDynamicContext.bind() methods. Predefined QNames for built-in types can be found in XTypeConstants.

Parameters:
name - The name of the variable.
type - The type of the variable.
Throws:
NullPointerException - if name, or type is null.
IllegalArgumentException - if the type is undefined.
See Also:
XDynamicContext, XTypeConstants

declareVariable

void declareVariable(QName name,
                     XSequenceType type)
Add a variable binding to the static context. Note that this simply declares the variable, a value must be bound to the XDynamicContext. See the XDynamicContext.bind() methods. The XSequenceTypeFactory can be used to create sequence types.

Parameters:
name - The name of the variable.
type - The sequence of the variable.
Throws:
NullPointerException - if name, or type is null.
See Also:
XDynamicContext, XSequenceTypeFactory, XFactory.getSequenceTypeFactory()

getVariableType

XSequenceType getVariableType(QName name)
Get the type of a variable binding.

Parameters:
name - The name of the variable.
Returns:
The type of the variable
Throws:
NullPointerException - if name is null.

setFeature

void setFeature(String name,
                boolean value)

Set a feature for this static context.

Feature names should be fully qualified URIs. Implementations may define their own features.

Note: there are no currently defined features, this is for future use.

Parameters:
name - Feature name.
value - Is feature state true or false.
Throws:
NullPointerException - if name is null.

getFeature

boolean getFeature(String name)

Get the state of the named feature.

Feature names should be fully qualified URIs. Implementations may define their own features. Info keys and feature keys must be unique from each other, so that the same table can be used for both.

Note: there are no currently defined features, this is for future use.

Parameters:
name - Feature name.
Returns:
State of the named feature.
Throws:
NullPointerException - if name is null.

setMessageHandler

void setMessageHandler(XMessageHandler handler)
Set a message handler to process static errors and messages.

Parameters:
handler - The error handler.
Throws:
NullPointerException - if handler is null.
See Also:
XMessageHandler

getMessageHandler

XMessageHandler getMessageHandler()
Get the static message handler.

Returns:
The message handler or null if no message handler has been registered.

getIntegerMathMode

int getIntegerMathMode()
Get the integer math mode, which is a constant representing the level of precision required and whether overflow detection is required when working with xs:integer values.

Returns:
The integer math mode value, one of: INTEGER_MATH_MODE_LIMITED_PRECISION, INTEGER_MATH_MODE_ARBITRARY_PRECISION, INTEGER_MATH_MODE_OVERFLOW_DETECTION.

setIntegerMathMode

void setIntegerMathMode(int mode)
Set the integer math mode, which is a constant representing the level of precision required and whether overflow detection is required when working with xs:integer values. The default is INTEGER_MATH_MODE_LIMITED_PRECISION.

Parameters:
mode - The integer math mode value, one of: INTEGER_MATH_MODE_LIMITED_PRECISION, INTEGER_MATH_MODE_ARBITRARY_PRECISION, INTEGER_MATH_MODE_OVERFLOW_DETECTION.
Throws:
IllegalArgumentException - if mode is not one of: INTEGER_MATH_MODE_LIMITED_PRECISION, INTEGER_MATH_MODE_ARBITRARY_PRECISION, INTEGER_MATH_MODE_OVERFLOW_DETECTION.

setUseCompiler

void setUseCompiler(boolean value)
Set whether to use the compiler when preparing an expression (as opposed to the interpreter). Note that this only applies to the XFactory prepare methods. The XCompilationFactory compile methods always use the compiler.

Parameters:
value - Pass in true to use the compiler, false to use the interpreter. The default is to use the interpreter.

getUseCompiler

boolean getUseCompiler()
Get the use compiler setting.

Returns:
The use compiler setting as a boolean.

getModuleResolver

XModuleResolver getModuleResolver()
Get the registered resolver for XQuery modules.

Returns:
The XModuleResolver if set, otherwise null.

setModuleResolver

void setModuleResolver(XModuleResolver moduleResolver)
Register a resolver for XQuery modules. Pass in null for the moduleResolver to restore the default module resolution behaviour. The default behaviour for resolving modules is to use the base URI of the importing module to resolve the imported module's location. If the base URI is not available, the current working directory will be used. The processor will attempt to locate one module per location hint. If no modules can be located for the target namespace, an error will be raised.

Parameters:
moduleResolver - The module resolver or null.
See Also:
XModuleResolver

IBM Copyright 2004-2008