|
API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
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:
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. |
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 |
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 |
|---|
static final int BOUNDARY_SPACE_PRESERVE
setBoundarySpacePolicy(int),
Constant Field Valuesstatic final int BOUNDARY_SPACE_STRIP
setBoundarySpacePolicy(int),
Constant Field Valuesstatic final int CONSTRUCTION_MODE_PRESERVE
xs:anyType, and all attribute and element nodes copied during
node construction retain their original types.
setConstructionMode(int),
Constant Field Valuesstatic final int CONSTRUCTION_MODE_STRIP
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.
setConstructionMode(int),
Constant Field Valuesstatic final int ORDERING_MODE_ORDERED
setOrderingMode(int),
Constant Field Valuesstatic final int ORDERING_MODE_UNORDERED
setOrderingMode(int),
Constant Field Valuesstatic final int DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST
setDefaultOrderForEmptySequences(int),
Constant Field Valuesstatic final int DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST
setDefaultOrderForEmptySequences(int),
Constant Field Valuesstatic final int COPY_NAMESPACES_MODE_PRESERVE
setCopyNamespacesModePreserve(int),
Constant Field Valuesstatic final int COPY_NAMESPACES_MODE_NO_PRESERVE
setCopyNamespacesModePreserve(int),
Constant Field Valuesstatic final int COPY_NAMESPACES_MODE_INHERIT
setCopyNamespacesModeInherit(int),
Constant Field Valuesstatic final int COPY_NAMESPACES_MODE_NO_INHERIT
setCopyNamespacesModeInherit(int),
Constant Field Valuesstatic final int INTEGER_MATH_MODE_LIMITED_PRECISION
xs:integer values need only support the
minimum precision required for a minimally conforming processor (18 digits).
setIntegerMathMode(int),
Constant Field Valuesstatic final int INTEGER_MATH_MODE_ARBITRARY_PRECISION
xs:integer values should support
an arbitrary number of digits of precision. No overflow should occur.
setIntegerMathMode(int),
Constant Field Valuesstatic final int INTEGER_MATH_MODE_OVERFLOW_DETECTION
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.
setIntegerMathMode(int),
Constant Field Valuesstatic final int XPATH_LATEST_VERSION
setXPathCompatibilityMode(int),
Constant Field Valuesstatic final int XPATH1_0_BC_COMPATIBILITY
setXPathCompatibilityMode(int),
Constant Field Valuesstatic final int XPATH2_0_PURE_COMPATIBILITY
setXPathCompatibilityMode(int),
Constant Field Valuesstatic final String UNICODE_CODE_POINT_COLLATION_URI
| Method Detail |
|---|
String getNamespaceURI(String prefix)
prefix - The prefix. Cannot be null.
null if the prefix is unknown.
NullPointerException - if prefix is null.
void declareNamespace(String prefix,
String uri)
prefix - The prefix. Cannot be null.uri - The namespace URI. An empty string undeclares the
specified prefix. Cannot be null.
NullPointerException - if prefix or uri
is null.String getDefaultElementTypeNamespace()
This setting does not apply to XSLT which uses the
[xsl:]xpath-default-namespace attribute to
set the default element/type namespace.
void setDefaultElementTypeNamespace(String uri)
This setting does not apply to XSLT which uses the
[xsl:]xpath-default-namespace attribute to
set the default element/type namespace.
uri - The namespace URI of the default element/type namespace,
or the empty string to make it unspecified. Cannot be null.
NullPointerException - if uri is null.String getDefaultFunctionNamespace()
This setting does not apply to XSLT which uses the standard function namespace defined in Functions and Operators for the default function namespace.
null.void setDefaultFunctionNamespace(String uri)
This setting does not apply to XSLT which uses the standard function namespace defined in Functions and Operators for the default function namespace.
uri - The namespace URI of the default function namespace,
or the empty string to make it unspecified. Cannot be
null.
NullPointerException - if uri is null.String getDefaultCollation()
void setDefaultCollation(String uri)
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.
uri - The URI reference for the default collation URI
NullPointerException - if uri is null
IllegalArgumentException - if uri is a relative URI
referenceUNICODE_CODE_POINT_COLLATION_URIString getDefaultCollationForXSLSort()
xsl:sort element that does not have any collation,
lang or case-order attributes, as set by a
call to setDefaultCollationForXSLSort(String).
xsl:sort elementssetDefaultCollationForXSLSort(String)void setDefaultCollationForXSLSort(String uri)
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()
uri - The URI reference for the default collation URI for
xsl:sort. A null reference restores the usual default
behaviour
IllegalArgumentException - if uri is a relative URI
referenceint getConstructionMode()
This setting is XQuery specific.
CONSTRUCTION_MODE_PRESERVE,
CONSTRUCTION_MODE_STRIPvoid setConstructionMode(int mode)
CONSTRUCTION_MODE_PRESERVE.
This setting is XQuery specific.
mode - The construction mode value. One of:
CONSTRUCTION_MODE_PRESERVE,
CONSTRUCTION_MODE_STRIP.
IllegalArgumentException - if mode is not one of:
CONSTRUCTION_MODE_PRESERVE,
CONSTRUCTION_MODE_STRIP.int getOrderingMode()
This setting is XQuery specific.
ORDERING_MODE_ORDERED,
ORDERING_MODE_UNORDERED.void setOrderingMode(int mode)
ORDERING_MODE_ORDERED.
This setting is XQuery specific.
mode - The ordering mode value. One of:
ORDERING_MODE_ORDERED,
ORDERING_MODE_UNORDERED.
IllegalArgumentException - if mode is not one of:
ORDERING_MODE_ORDERED,
ORDERING_MODE_UNORDERED.int getDefaultOrderForEmptySequences()
This setting is XQuery specific.
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST,
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.void setDefaultOrderForEmptySequences(int order)
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.
This setting is XQuery specific.
order - The default order for empty sequences. One of:
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST,
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.
IllegalArgumentException - if order is not one of:
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST,
DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST.int getBoundarySpacePolicy()
This setting is XQuery specific.
BOUNDARY_SPACE_PRESERVE,
BOUNDARY_SPACE_STRIP.void setBoundarySpacePolicy(int policy)
BOUNDARY_SPACE_STRIP.
This setting is XQuery specific.
policy - The boundary space policy. One of:
BOUNDARY_SPACE_PRESERVE,
BOUNDARY_SPACE_STRIP.
IllegalArgumentException - if policy is not one of:
BOUNDARY_SPACE_PRESERVE,
BOUNDARY_SPACE_STRIP.int getCopyNamespacesModePreserve()
This setting is XQuery specific.
COPY_NAMESPACES_MODE_PRESERVE,
COPY_NAMESPACES_MODE_NO_PRESERVE.void setCopyNamespacesModePreserve(int mode)
COPY_NAMESPACES_MODE_PRESERVE.
This setting is XQuery specific.
mode - The copy-namespaces preserve mode value. One of:
COPY_NAMESPACES_MODE_PRESERVE,
COPY_NAMESPACES_MODE_NO_PRESERVE.
IllegalArgumentException - if mode is not one of:
COPY_NAMESPACES_MODE_PRESERVE,
COPY_NAMESPACES_MODE_NO_PRESERVE.int getCopyNamespacesModeInherit()
This setting is XQuery specific.
COPY_NAMESPACES_MODE_INHERIT,
COPY_NAMESPACES_MODE_NO_INHERIT.void setCopyNamespacesModeInherit(int mode)
COPY_NAMESPACES_MODE_INHERIT.
This setting is XQuery specific.
mode - The copy-namespaces inherit mode value. One of:
COPY_NAMESPACES_MODE_INHERIT,
COPY_NAMESPACES_MODE_NO_INHERIT.
IllegalArgumentException - if mode is not one of:
COPY_NAMESPACES_MODE_INHERIT,
COPY_NAMESPACES_MODE_NO_INHERIT.String getBaseURI()
null.
null.void setBaseURI(String uri)
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.
uri - The new base URI, or null.XSourceResolver getSourceResolver()
XSourceResolver if set, otherwise null.void setSourceResolver(XSourceResolver sourceResolver)
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.
sourceResolver - The source resolver or null.XSourceResolverint getXPathCompatibilityMode()
XPATH2_0_PURE_COMPATIBILITY,
XPATH1_0_BC_COMPATIBILITY.void setXPathCompatibilityMode(int mode)
mode - The XPath compatibility mode, one of:
XPATH2_0_PURE_COMPATIBILITY,
XPATH1_0_BC_COMPATIBILITY,
XPATH_LATEST_VERSION.
IllegalArgumentException - if mode is not one of:
XPATH2_0_PURE_COMPATIBILITY,
XPATH1_0_BC_COMPATIBILITY,
XPATH_LATEST_VERSION.Enumeration<String> getNamespacePrefixes(String namespaceURI)
namespaceURI - URI of namespace to look up.
namespaceURI
in the current scope.
void declareFunction(QName name,
QName type,
QName[] argTypes)
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.
name - The name of the function.type - The return type of the function.argTypes - The argument types for the function.
NullPointerException - if any of name, type,
or argTypes is null.
IllegalArgumentException - if the type or any of the
argTypes are undefined.XDynamicContext.bindFunction(QName, java.lang.reflect.Method),
XDynamicContext.bindFunction(QName, java.lang.reflect.Method, Object),
XTypeConstants
void declareFunction(QName name,
XSequenceType type,
XSequenceType[] argTypes)
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.
name - The name of the function.type - the return type of the function.argTypes - the argument types for the function.
NullPointerException - if any of name, type,
or argTypes is null.XDynamicContext.bindFunction(QName, java.lang.reflect.Method),
XDynamicContext.bindFunction(QName, java.lang.reflect.Method, Object),
XSequenceTypeFactory,
XFactory.getSequenceTypeFactory()
XSequenceType getFunctionReturnType(QName name,
int arity)
name - The name of the function.arity - The arity (number of parameters) of the function.
NullPointerException - if name is null.
IllegalArgumentException - if the arity
XSequenceType[] getFunctionArgTypes(QName name,
int arity)
name - The name of the Function.arity - The arity (number of parameters) of the function.
NullPointerException - if name is null.
IllegalArgumentException - if the arity
void declareVariable(QName name,
QName type)
XDynamicContext. See the XDynamicContext.bind()
methods.
Predefined QNames for built-in types can be found in XTypeConstants.
name - The name of the variable.type - The type of the variable.
NullPointerException - if name, or type
is null.
IllegalArgumentException - if the type is undefined.XDynamicContext,
XTypeContstants
void declareVariable(QName name,
XSequenceType type)
XDynamicContext. See the XDynamicContext.bind()
methods.
The XSequenceTypeFactory can be used to create sequence types.
name - The name of the variable.type - The sequence of the variable.
NullPointerException - if name, or type
is null.XDynamicContext,
XSequenceTypeFactory,
XFactory.getSequenceTypeFactory()XSequenceType getVariableType(QName name)
name - The name of the variable.
NullPointerException - if name is null.
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.
name - Feature name.value - Is feature state true or false.
NullPointerException - if name is null.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.
name - Feature name.
NullPointerException - if name is null.void setMessageHandler(XMessageHandler handler)
handler - The error handler.
NullPointerException - if handler is null.XMessageHandlerXMessageHandler getMessageHandler()
null if no
message handler has been registered.int getIntegerMathMode()
xs:integer values.
INTEGER_MATH_MODE_LIMITED_PRECISION,
INTEGER_MATH_MODE_ARBITRARY_PRECISION,
INTEGER_MATH_MODE_OVERFLOW_DETECTION.void setIntegerMathMode(int mode)
xs:integer values.
The default is INTEGER_MATH_MODE_LIMITED_PRECISION.
mode - The integer math mode value, one of:
INTEGER_MATH_MODE_LIMITED_PRECISION,
INTEGER_MATH_MODE_ARBITRARY_PRECISION,
INTEGER_MATH_MODE_OVERFLOW_DETECTION.
IllegalArgumentException - if mode is not one of:
INTEGER_MATH_MODE_LIMITED_PRECISION,
INTEGER_MATH_MODE_ARBITRARY_PRECISION,
INTEGER_MATH_MODE_OVERFLOW_DETECTION.void setUseCompiler(boolean value)
XFactory prepare
methods. The XCompilationFactory compile methods always use the compiler.
value - Pass in true to use the compiler, false
to use the interpreter. The default is to use the interpreter.boolean getUseCompiler()
|
IBM Copyright 2004-2008 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||