net.sf.saxon.expr.instruct

## Class LocalParam

- java.lang.Object
- - net.sf.saxon.expr.instruct.GeneralVariable
  - - net.sf.saxon.expr.instruct.LocalParam

- All Implemented Interfaces:
    SourceLocator, Binding

      public final class LocalParam
      extends GeneralVariable

  The compiled form of an xsl:param element within a template in an XSLT stylesheet.

  The xsl:param element in XSLT has mandatory attribute name and optional attribute select. It can also be specified as required="yes" or required="no".

  This is used only for parameters to XSLT templates. For function calls, the caller of the function places supplied arguments onto the callee's stackframe and the callee does not need to do anything. Global parameters (XQuery external variables) are handled using `GlobalParam`.

  The LocalParam class is also used to represent parameters with the saxon:iterate instruction

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.expr.instruct.GeneralVariable

      `evaluationMode, referenceCount, slotNumber, variableQName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LocalParam()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Sequence` | `evaluateVariable(XPathContext c)` Evaluate the variable
    `void` | `explain(ExpressionPresenter out)` Diagnostic print of expression structure.
    `Expression` | `getConversion()` Get the conversion expression
    `int` | `getConversionEvaluationMode()`
    `int` | `getInstructionNameCode()` Get the name of this instruction for diagnostic and tracing purposes
    `IntegerValue[]` | `getIntegerBoundsForVariable()` If the variable is bound to an integer, get the minimum and maximum possible values.
    `int` | `getParameterId()` Get the parameter id, which is essentially an alias for the parameter name, unique within a stylesheet
    `Iterator<Expression>` | `iterateSubExpressions()` Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)
    `TailCall` | `processLeavingTail(XPathContext context)` Process the local parameter declaration
    `boolean` | `replaceSubExpression(Expression original, Expression replacement)` Replace one subexpression by a replacement subexpression
    `void` | `setConversion(Expression convertor)` Define a conversion that is to be applied to the supplied parameter value.
    `void` | `setParameterId(int id)` Allocate a number which is essentially an alias for the parameter name, unique within a stylesheet

    - ### Methods inherited from class net.sf.saxon.expr.instruct.GeneralVariable

      `addReference, checkAgainstRequiredType, computeEvaluationMode, copy, getCardinality, getColumnNumber, getContainer, getEvaluationMode, getExecutable, getLineNumber, getLocalSlotNumber, getLocationId, getLocationProvider, getPublicId, getRequiredType, getSelectExpression, getSelectValue, getSlotNumber, getSystemId, getSystemId, getVariableQName, init, isAssignable, isGlobal, isImplicitlyRequiredParam, isRequiredParam, isTunnelParam, optimize, setContainer, setImplicitlyRequiredParam, setLocationId, setReferenceCount, setRequiredParam, setRequiredType, setSelectExpression, setSlotNumber, setTunnel, setVariableQName, simplify, typeCheck`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LocalParam

          public LocalParam()

  - ### Method Detail

    - #### setParameterId

          public void setParameterId(int id)

      Allocate a number which is essentially an alias for the parameter name, unique within a stylesheet
      Parameters:
        `id` - the parameter id

    - #### getParameterId

          public int getParameterId()

      Get the parameter id, which is essentially an alias for the parameter name, unique within a stylesheet
      Returns:
        the parameter id

    - #### setConversion

          public void setConversion(Expression convertor)

      Define a conversion that is to be applied to the supplied parameter value.
      Parameters:
        `convertor` - The expression to be applied. This performs type checking, and the basic conversions implied by function calling rules, for example numeric promotion, atomization, and conversion of untyped atomic values to a required type. The conversion uses the actual parameter value as input, referencing it using a VariableReference. The argument can be null to indicate that no conversion is required.

    - #### getConversion

          public Expression getConversion()

      Get the conversion expression
      Returns:
        the expression used to convert the value to the required type, or null if there is none

    - #### getConversionEvaluationMode

          public int getConversionEvaluationMode()

    - #### getInstructionNameCode

          public int getInstructionNameCode()

      Get the name of this instruction for diagnostic and tracing purposes
      Overrides:
        `getInstructionNameCode` in class `GeneralVariable`
      Returns:
        the name of this instruction, as a name pool name code

    - #### iterateSubExpressions

          public Iterator<Expression> iterateSubExpressions()

      Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)
      Overrides:
        `iterateSubExpressions` in class `GeneralVariable`
      Returns:
        an iterator over all the contained expressions (in practice, the select expression)

    - #### replaceSubExpression

          public boolean replaceSubExpression(Expression original,
                                     Expression replacement)

      Replace one subexpression by a replacement subexpression
      Overrides:
        `replaceSubExpression` in class `GeneralVariable`
      Parameters:
        `original` - the original subexpression
        `replacement` - the replacement subexpression
      Returns:
        true if the original subexpression is found

    - #### processLeavingTail

          public TailCall processLeavingTail(XPathContext context)
                                      throws XPathException

      Process the local parameter declaration
      Parameters:
        `context` - the dynamic context
      Returns:
        either null if processing is complete, or a tailcall if one is left outstanding
      Throws:
        `XPathException` - if a dynamic error occurs in the evaluation

    - #### getIntegerBoundsForVariable

          public IntegerValue[] getIntegerBoundsForVariable()

      If the variable is bound to an integer, get the minimum and maximum possible values. Return null if unknown or not applicable
      Specified by:
        `getIntegerBoundsForVariable` in interface `Binding`
      Overrides:
        `getIntegerBoundsForVariable` in class `GeneralVariable`
      Returns:
        a pair of integers containing the minimum and maximum values for the integer value; or null if the value is not an integer or the range is unknown

    - #### evaluateVariable

          public Sequence evaluateVariable(XPathContext c)

      Evaluate the variable
      Parameters:
        `c` - the XPath dynamic evaluation context
      Returns:
        the result of evaluating the variable

    - #### explain

          public void explain(ExpressionPresenter out)

      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Overrides:
        `explain` in class `GeneralVariable`
      Parameters:
        `out` - the object used to present the output

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.