Package net.sf.saxon.expr.instruct

## Class UseAttributeSet

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.instruct.Instruction
    - - net.sf.saxon.expr.instruct.UseAttributeSet

- All Implemented Interfaces:
    `ComponentInvocation`, `ContextOriginator`, `ExportAgent`, `TailCallReturner`, `Locatable`, `IdentityComparable`, `Traceable`

      public class UseAttributeSet
      extends Instruction
      implements ComponentInvocation, ContextOriginator

  This instruction corresponds to a single QName appearing within a use-attribute-sets attribute on a literal result element, xsl:element, or xsl:copy instruction. Binding to a specific attribute set component is done in the same way as function calls or call-template, allowing attribute sets defined in one package to be overridden in another.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.expr.Expression

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `UseAttributeSet​(StructuredQName name, boolean streamable)` | Create a use-attribute-set expression

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `computeHashCode()` | Compute a hashcode
    `Expression` | `copy​(RebindingMap rebindings)` | Copy an expression.
    `boolean` | `equals​(java.lang.Object obj)` | Test whether this UseAttributeSets expression is equal to another
    `void` | `export​(ExpressionPresenter out)` | Export of expression structure.
    `int` | `getBindingSlot()` | Get the binding slot to be used.
    `java.lang.String` | `getExpressionName()` | Get a name identifying the kind of expression, in terms meaningful to a user.
    `Component` | `getFixedTarget()` | Get the target component if this is known in advance, that is, if the target component is private or final, or in some other cases such as xsl:original.
    `int` | `getIntrinsicDependencies()` | Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.
    `ItemType` | `getItemType()` | Get the item type of the items returned by evaluating this instruction
    `java.lang.String` | `getStreamerName()` | Get the (partial) name of a class that supports streaming of this kind of expression
    `SymbolicName` | `getSymbolicName()` | Get the symbolic name of the component that this invocation references
    `AttributeSet` | `getTargetAttributeSet()` | Get the target attribute set to which this instruction is provisionally bound
    `StructuredQName` | `getTargetAttributeSetName()` | Get the target attribute sets of this instruction.
    `boolean` | `isDeclaredStreamable()` |
    `boolean` | `isInstruction()` | Ask whether this expression is an instruction.
    `static Expression` | `makeCompositeExpression​(java.util.List<UseAttributeSet> targets)` | Given a list of UseAttributeSet expressions, combine them into a single expression
    `static java.util.List<UseAttributeSet>` | `makeUseAttributeSetInstructions​(StructuredQName[] targets, StyleElement instruction)` | Make an list of expressions whose combined effect is to expand the attribute sets named in an [xsl]use-attribute-sets attribute, for example on a literal result element
    `static Expression` | `makeUseAttributeSets​(StructuredQName[] targets, StyleElement instruction)` | Make an expression whose effect is to expand the attribute sets named in an [xsl]use-attribute-sets attribute, for example on a literal result element
    `java.lang.Iterable<Operand>` | `operands()` | Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.
    `Expression` | `optimize​(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)` | Perform optimisation of an expression and its subexpressions.
    `TailCall` | `processLeavingTail​(Outputter output, XPathContext context)` | ProcessLeavingTail: called to do the real work of this instruction.
    `void` | `setBindingSlot​(int slot)` | Set the binding slot to be used.
    `void` | `setTarget​(AttributeSet target)` | Set the attribute set to be used.
    `Expression` | `typeCheck​(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)` | Perform type checking of an expression and its subexpressions.

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

      `alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionNameCode, getNetCost, getSourceLocator, isXSLT, iterate, mayCreateNewNodes, process, someOperandCreatesNewNodes`

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

      `addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.trace.Traceable

      `gatherProperties`

- - ### Constructor Detail

    - #### UseAttributeSet

          public UseAttributeSet​(StructuredQName name,
                                 boolean streamable)

      Create a use-attribute-set expression
      Parameters:
        `name` - the name of the target attribute set

  - ### Method Detail

    - #### isInstruction

          public boolean isInstruction()

      Description copied from class: `Expression`
      Ask whether this expression is an instruction. In XSLT streamability analysis this is used to distinguish constructs corresponding to XSLT instructions from other constructs, typically XPath expressions (but also things like attribute constructors on a literal result element, references to attribute sets, etc. However, an XPath expression within a text value template in a text node of an XSLT stylesheet is treated as an instruction. In a non-XSLT environment (such as XQuery) this property has no meaning and its setting is undefined.
      Overrides:
        `isInstruction` in class `Instruction`
      Returns:
        true if this construct originates as an XSLT instruction

    - #### makeUseAttributeSets

          public static Expression makeUseAttributeSets​(StructuredQName[] targets,
                                                        StyleElement instruction)
                                                 throws XPathException

      Make an expression whose effect is to expand the attribute sets named in an [xsl]use-attribute-sets attribute, for example on a literal result element
      Parameters:
        `targets` - the QNames contained in the use-attribute-sets attribute
        `instruction` - the instruction on which the use-attribute-sets attribute appears
      Returns:
        the required expression
      Throws:
        `XPathException` - if an error occurs, for example no attribute set found with the required name

    - #### makeUseAttributeSetInstructions

          public static java.util.List<UseAttributeSet> makeUseAttributeSetInstructions​(StructuredQName[] targets,
                                                                                        StyleElement instruction)
                                                                                 throws XPathException

      Make an list of expressions whose combined effect is to expand the attribute sets named in an [xsl]use-attribute-sets attribute, for example on a literal result element
      Parameters:
        `targets` - the QNames contained in the use-attribute-sets attribute
        `instruction` - the instruction on which the use-attribute-sets attribute appears
      Returns:
        the required expression
      Throws:
        `XPathException` - if an error occurs, for example no attribute set found with the required name

    - #### makeCompositeExpression

          public static Expression makeCompositeExpression​(java.util.List<UseAttributeSet> targets)

      Given a list of UseAttributeSet expressions, combine them into a single expression
      Parameters:
        `targets` - the list of expressions
      Returns:
        the combined expression

    - #### isDeclaredStreamable

          public boolean isDeclaredStreamable()

    - #### setTarget

          public void setTarget​(AttributeSet target)

      Set the attribute set to be used.
      Parameters:
        `target` - the attribute set to be used

    - #### setBindingSlot

          public void setBindingSlot​(int slot)

      Set the binding slot to be used. This is the offset within the binding vector of the containing component where the actual target component is to be found. The target template is not held directly in the invocation instruction/expression itself because it can be overridden in a using package.
      Specified by:
        `setBindingSlot` in interface `ComponentInvocation`
      Parameters:
        `slot` - the offset in the binding vector of the containing package where the target component can be found.

    - #### getBindingSlot

          public int getBindingSlot()

      Get the binding slot to be used. This is the offset within the binding vector of the containing component where the actual target component is to be found.
      Specified by:
        `getBindingSlot` in interface `ComponentInvocation`
      Returns:
        the offset in the binding vector of the containing package where the target component can be found.

    - #### getSymbolicName

          public SymbolicName getSymbolicName()

      Get the symbolic name of the component that this invocation references
      Specified by:
        `getSymbolicName` in interface `ComponentInvocation`
      Returns:
        the symbolic name of the target component

    - #### getTargetAttributeSet

          public AttributeSet getTargetAttributeSet()

      Get the target attribute set to which this instruction is provisionally bound
      Returns:
        the provisional attribute set (which might be overridden in another package)

    - #### getFixedTarget

          public Component getFixedTarget()

      Description copied from interface: `ComponentInvocation`
      Get the target component if this is known in advance, that is, if the target component is private or final, or in some other cases such as xsl:original. Otherwise, return null.
      Specified by:
        `getFixedTarget` in interface `ComponentInvocation`
      Returns:
        the bound component if the binding has been fixed

    - #### operands

          public java.lang.Iterable<Operand> operands()

      Description copied from class: `Expression`
      Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()

      If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.

      Specified by:
        `operands` in class `Instruction`
      Returns:
        an iterator containing the sub-expressions of this expression

    - #### optimize

          public Expression optimize​(ExpressionVisitor visitor,
                                     ContextItemStaticInfo 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.

      Overrides:
        `optimize` in class `Expression`
      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)

    - #### copy

          public Expression copy​(RebindingMap rebindings)

      Copy an expression. This makes a deep copy.
      Specified by:
        `copy` in class `Expression`
      Parameters:
        `rebindings` - a mutable list of (old binding, new binding) pairs that is used to update the bindings held in any local variable references that are copied.
      Returns:
        the copy of the original expression

    - #### typeCheck

          public Expression typeCheck​(ExpressionVisitor visitor,
                                      ContextItemStaticInfo contextInfo)
                               throws XPathException

      Perform type checking of an expression and its subexpressions.

      This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.

      This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.

      Overrides:
        `typeCheck` in class `Expression`
      Parameters:
        `visitor` - an expression visitor
        `contextInfo` - information about the static type of the context item
      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)

    - #### getItemType

          public ItemType getItemType()

      Get the item type of the items returned by evaluating this instruction
      Overrides:
        `getItemType` in class `Instruction`
      Returns:
        the static item type of the instruction

    - #### getIntrinsicDependencies

          public int getIntrinsicDependencies()

      Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".
      Overrides:
        `getIntrinsicDependencies` in class `Expression`
      Returns:
        a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty

    - #### getTargetAttributeSetName

          public StructuredQName getTargetAttributeSetName()

      Get the target attribute sets of this instruction. Called from generated bytecode.
      Returns:
        the target attribute sets, as an array

    - #### processLeavingTail

          public TailCall processLeavingTail​(Outputter output,
                                             XPathContext context)
                                      throws XPathException

      ProcessLeavingTail: called to do the real work of this instruction. This method must be implemented in each subclass. The results of the instruction are written to the current Receiver, which can be obtained via the Controller.
      Specified by:
        `processLeavingTail` in interface `TailCallReturner`
      Specified by:
        `processLeavingTail` in class `Instruction`
      Parameters:
        `output` - the destination for the result
        `context` - The dynamic context of the transformation, giving access to the current node, the current variables, etc.
      Returns:
        null if the instruction has completed execution; or a TailCall indicating a function call or template call that is delegated to the caller, to be made after the stack has been unwound so as to save stack space.
      Throws:
        `XPathException` - if a dynamic error occurs during the evaluation of the instruction

    - #### getExpressionName

          public java.lang.String getExpressionName()

      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
        `getExpressionName` in class `Instruction`
      Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.

    - #### export

          public void export​(ExpressionPresenter out)
                      throws XPathException

      Export of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
        `export` in interface `ExportAgent`
      Specified by:
        `export` in class `Expression`
      Parameters:
        `out` - the expression presenter used to display the structure
      Throws:
        `XPathException` - if the export fails, for example if an expression is found that won't work in the target environment.

    - #### equals

          public boolean equals​(java.lang.Object obj)

      Test whether this UseAttributeSets expression is equal to another
      Overrides:
        `equals` in class `Expression`
      Parameters:
        `obj` - the other expression
      Returns:
        true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.

    - #### computeHashCode

          public int computeHashCode()

      Compute a hashcode
      Overrides:
        `computeHashCode` in class `Expression`
      Returns:
        a computed hash code

    - #### getStreamerName

          public java.lang.String getStreamerName()

      Get the (partial) name of a class that supports streaming of this kind of expression
      Overrides:
        `getStreamerName` in class `Expression`
      Returns:
        the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class