net.sf.saxon.functions
Class SystemFunction
- EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator
public abstract class SystemFunction
Abstract superclass for system-defined and user-defined functions
addExternalFunctionCallToPathMap , checkArgumentCount , checkArguments , equals , explain , getArguments , getDisplayName , getFunctionName , getNumberOfArguments , hashCode , iterateSubExpressions , optimize , preEvaluate , promote , replaceSubExpression , setArguments , setFunctionName , simplify , simplifyArguments , toString , typeCheck |
addToPathMap , adoptChildExpression , checkPermittedContents , computeCardinality , computeDependencies , computeSpecialProperties , computeStaticProperties , copy , display , doPromotion , dynamicError , effectiveBooleanValue , evaluateAsString , evaluateItem , explain , explain , findParentOf , getCardinality , getColumnNumber , getConstructType , getContainer , getDependencies , getExecutable , getHostLanguage , getImplementationMethod , getInstructionInfo , getIntrinsicDependencies , getItemType , getLineNumber , getLocationId , getLocationProvider , getPublicId , getSlotsUsed , getSpecialProperties , getSystemId , hasLoopingSubexpression , implementsStaticTypeCheck , iterate , iterateEvents , iterateSubExpressions , markTailFunctionCalls , optimize , process , promote , replaceSubExpression , resetLocalStaticProperties , setContainer , setFiltered , setFlattened , setLocationId , simplify , staticTypeCheck , suppressValidation , toString , typeCheck , typeError |
operation
protected int operation
addContextDocumentArgument
protected final void addContextDocumentArgument(int pos,
String augmentedName)
throws XPathException
Add an implicit argument referring to the context document. Called by functions such as
id() and key() that take the context document as an implicit argument
pos
- the position of the argument whose default value is ".", zero-basedaugmentedName
- the name to be used for the function call with its extra argument.
There are some cases where user function calls cannot supply the argument directly (notably
unparsed-entity-uri() and unparsed-entity-public-id()) and in these cases a synthesized
function name is used for the new function call.
addDocToPathMap
public PathMap.PathMapNodeSet addDocToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodes)
Add a representation of a doc() call or similar function to a PathMap.
This is a convenience method called by the addToPathMap() methods for doc(), document(), collection()
and similar functions. These all create a new root expression in the path map.
pathMap
- the PathMap to which the expression should be addedpathMapNodes
- the node in the PathMap representing the focus at the point where this expression
is called. Set to null if this expression appears at the top level.
- the pathMapNode representing the focus established by this expression, in the case where this
expression is the first operand of a path expression or filter expression
computeSpecialProperties
public int computeSpecialProperties()
Determine the special properties of this expression. The general rule
is that a system function call is non-creative if its return type is
atomic, or if all its arguments are non-creative. This is overridden
for the generate-id() function, which is considered creative if
its operand is creative (because the result depends on the
identity of the operand)
- computeSpecialProperties in interface Expression
copy
public Expression copy()
Copy an expression. This makes a deep copy.
- copy in interface Expression
- the copy of the original expression
getDetails
public StandardFunction.Entry getDetails()
Get the details of the function signature
- information about the function signature
getErrorCodeForTypeErrors
public String getErrorCodeForTypeErrors()
Return the error code to be used for type errors. This is overridden for functions
such as exactly-one(), one-or-more(), ...
- the error code to be used for type errors in the function call. Normally XPTY0004,
but different codes are used for functions such as exactly-one()
getRequiredType
protected SequenceType getRequiredType(int arg)
Get the required type of the nth argument
arg
- the number of the argument whose type is requested, zero-based
- the required type of the argument as defined in the function signature
makeSystemFunction
public static FunctionCall makeSystemFunction(String name,
Expression[] arguments)
Make a system function call (one in the standard function namespace).
name
- The local name of the function.arguments
- the arguments to the function call
- a FunctionCall that implements this function, if it
exists, or null if the function is unknown.
optimize
public Expression optimize(ExpressionVisitor visitor,
ItemType contextItemType)
throws XPathException
Perform optimisation of an expression and its subexpressions.
This method is called after all references to functions and variables have been resolved
to the declaration of the function or variable, and after all type checking has been done.
- optimize in interface FunctionCall
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
- the original expression, rewritten if appropriate to optimize execution
XPathException
- if an error is discovered during this phase
(typically a type error)
setDetails
public void setDetails(StandardFunction.Entry entry)
Set the details of this type of function
entry
- information giving details of the function signature
useContextItemAsDefault
protected final void useContextItemAsDefault()
Set "." as the default value for the first and only argument. Called from subclasses.