com.saxonica.extra
Class Try

java.lang.Object
  extended by net.sf.saxon.expr.Expression
      extended by net.sf.saxon.expr.FunctionCall
          extended by net.sf.saxon.functions.SystemFunction
              extended by com.saxonica.extra.Try
All Implemented Interfaces:
Serializable, SourceLocator, EvaluableItem, SequenceIterable, InstructionInfoProvider

public class Try
extends SystemFunction

This class implements the saxon:try() extension function, which is specially recognized by the system because it uses a non-standard approach to evaluating its arguments

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Constructor Summary
Try()
           
 
Method Summary
 int computeCardinality()
          Determine the cardinality of the function.
 Item evaluateItem(XPathContext c)
          Evaluate in a general context
 ItemType getItemType(TypeHierarchy th)
          Determine the item type of the value returned by the function
 SequenceIterator iterate(XPathContext c)
          Iterate over the results of the function
 Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)
          Type-check the expression.
 Expression simplify(ExpressionVisitor visitor)
          Simplify the function call.
 Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)
          Type-check the expression.
 
Methods inherited from class net.sf.saxon.functions.SystemFunction
addDocToPathMap, checkArguments, computeSpecialProperties, copy, getDetails, getErrorCodeForTypeErrors, makeSystemFunction, setDetails
 
Methods inherited from class net.sf.saxon.expr.FunctionCall
addExternalFunctionCallToPathMap, equals, explain, getArguments, getDisplayName, getFunctionName, getNumberOfArguments, hashCode, iterateSubExpressions, preEvaluate, promote, replaceSubExpression, setArguments, setFunctionName, toString
 
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, display, doPromotion, effectiveBooleanValue, evaluateAsString, explain, findParentOf, getCardinality, getColumnNumber, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterateEvents, markTailFunctionCalls, process, setContainer, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Try

public Try()
Method Detail

simplify

public Expression simplify(ExpressionVisitor visitor)
                    throws XPathException
Simplify the function call. Returns the value of the first argument if this is known statically.

Overrides:
simplify in class FunctionCall
Parameters:
visitor - an expression visitor
Returns:
the simplified expression
Throws:
XPathException - if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(ExpressionVisitor visitor,
                            ItemType contextItemType)
                     throws XPathException
Type-check the expression. This also calls preEvaluate() to evaluate the function if all the arguments are constant; functions that do not require this behavior can override the preEvaluate method.

Overrides:
typeCheck in class FunctionCall
Parameters:
visitor - an expression visitor
contextItemType - 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
Returns:
the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
Throws:
XPathException - if an error is discovered during this phase (typically a type error)

optimize

public Expression optimize(ExpressionVisitor visitor,
                           ItemType contextItemType)
                    throws XPathException
Type-check the expression. This also calls preEvaluate() to evaluate the function if all the arguments are constant; functions that do not require this behavior can override the preEvaluate method.

Overrides:
optimize in class SystemFunction
Parameters:
visitor - an expression visitor
contextItemType - 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
Returns:
the original expression, rewritten if appropriate to optimize execution
Throws:
XPathException - if an error is discovered during this phase (typically a type error)

computeCardinality

public int computeCardinality()
Determine the cardinality of the function.

Overrides:
computeCardinality in class SystemFunction
Returns:
the computed cardinality, as one of the values StaticProperty.ALLOWS_ZERO_OR_ONE, StaticProperty.EXACTLY_ONE, StaticProperty.ALLOWS_ONE_OR_MORE, StaticProperty.ALLOWS_ZERO_OR_MORE

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the item type of the value returned by the function

Overrides:
getItemType in class SystemFunction
Parameters:
th - the type hierarchy cache
Returns:
a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

evaluateItem

public Item evaluateItem(XPathContext c)
                  throws XPathException
Evaluate in a general context

Specified by:
evaluateItem in interface EvaluableItem
Overrides:
evaluateItem in class Expression
Parameters:
c - The context in which the expression is to be evaluated
Returns:
the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
Throws:
XPathException - if any dynamic error occurs evaluating the expression

iterate

public SequenceIterator iterate(XPathContext c)
                         throws XPathException
Iterate over the results of the function

Specified by:
iterate in interface SequenceIterable
Overrides:
iterate in class Expression
Parameters:
c - supplies the context for evaluation
Returns:
a SequenceIterator that can be used to iterate over the result of the expression
Throws:
XPathException - if any dynamic error occurs evaluating the expression


Copyright (C) Michael H. Kay. All rights reserved.