## com.saxonica.extra
Class Try

    java.lang.Object
      net.sf.saxon.expr.Expression
          net.sf.saxon.expr.FunctionCall
              net.sf.saxon.functions.SystemFunction
                  com.saxonica.extra.Try

All Implemented Interfaces:
  java.io.Serializable, javax.xml.transform.SourceLocator, LocationProvider, SaxonLocator, EvaluableItem, SequenceIterable, InstructionInfo, org.xml.sax.Locator

    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.functions.SystemFunction
`operation`

Fields inherited from class net.sf.saxon.expr.FunctionCall
`argument`

Fields inherited from class net.sf.saxon.expr.Expression
`EVALUATE_METHOD, ITERATE_METHOD, locationId, PROCESS_METHOD, staticProperties`

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
`addContextDocumentArgument, addDocToPathMap, checkArguments, computeSpecialProperties, copy, getDetails, getErrorCodeForTypeErrors, getRequiredType, makeSystemFunction, setDetails, useContextItemAsDefault`

Methods inherited from class net.sf.saxon.expr.FunctionCall
`addExternalFunctionCallToPathMap, checkArgumentCount, equals, explain, getArguments, getDisplayName, getFunctionName, getNumberOfArguments, hashCode, iterateSubExpressions, preEvaluate, promote, replaceSubExpression, setArguments, setFunctionName, simplifyArguments, toString`

Methods inherited from class net.sf.saxon.expr.Expression

`addToPathMap, adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, findParentOf, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, isUpdatingExpression, iterateEvents, markTailFunctionCalls, process, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError`

Methods inherited from class java.lang.Object
`clone, finalize, 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) Saxonica Limited. All rights reserved.