Class XPathEvalContext
java.lang.Object
org.libxmq.imp.xml.XPathEvalContext
An evaluation context, like XmlXPathContext in the C version (used by xslt): the document
order index and the id tables of the trees seen so far are kept between evaluations, and
variables and extension functions are resolved through callbacks. The trees must not
change while the context knows them: call
forget(XmlNode) before a tree is changed.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn extension function.static interfaceFinds extension functions.static interfaceResolves a variable reference, returns null if the variable is not defined. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe context node of the evaluation calling the function.Evaluate a compiled expression.voidForget the indexes of the tree with this root, before it is changed.The element with the id in the document of node.lookupNamespace(String prefix) Look up a prefix in the namespaces of the expression calling the function.longposition()The context position of the evaluation calling the function.voidsetError(int code) Set the error of a failing extension function (it returns null).voidsetErrorQuiet(int code) Set the error of a failing extension function that reported its own message.voidSet the extension function lookup.voidSet the variable lookup.longsize()The context size of the evaluation calling the function.voidsort(XPathResult r) Remove duplicates from a node set and sort it in document order, like a union.
-
Constructor Details
-
XPathEvalContext
public XPathEvalContext()A new context.
-
-
Method Details
-
setVariableLookup
Set the variable lookup.- Parameters:
lookup- The lookup, null for none.
-
setFunctionLookup
Set the extension function lookup.- Parameters:
lookup- The lookup, null for none.
-
forget
Forget the indexes of the tree with this root, before it is changed.- Parameters:
root- The root of the tree.
-
eval
Evaluate a compiled expression.- Parameters:
comp- The expression.node- The context node.position- The context position, -1 if unknown (then position() is an error).size- The context size, -1 if unknown (then last() is an error).- Returns:
- The value.
- Throws:
XPathException- On an error.
-
contextNode
The context node of the evaluation calling the function.- Returns:
- The node or null.
-
position
public long position()The context position of the evaluation calling the function.- Returns:
- The position or -1.
-
size
public long size()The context size of the evaluation calling the function.- Returns:
- The size or -1.
-
lookupNamespace
-
getId
-
setError
public void setError(int code) Set the error of a failing extension function (it returns null).- Parameters:
code- The XPathException code.
-
setErrorQuiet
public void setErrorQuiet(int code) Set the error of a failing extension function that reported its own message.- Parameters:
code- The XPathException code.
-
sort
Remove duplicates from a node set and sort it in document order, like a union.- Parameters:
r- The node set.
-