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
,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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UseAttributeSet.UseAttributeSetElaborator
-
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 protected int
computeHashCode()
Compute a hashcodeExpression
copy(RebindingMap rebindings)
Copy an expression.boolean
equals(java.lang.Object obj)
Test whether this UseAttributeSets expression is equal to anothervoid
export(ExpressionPresenter out)
Export of expression structure.int
getBindingSlot()
Get the binding slot to be used.Elaborator
getElaborator()
Make an elaborator for this expressionjava.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 instructionjava.lang.String
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expressionSymbolicName
getSymbolicName()
Get the symbolic name of the component that this invocation referencesAttributeSet
getTargetAttributeSet()
Get the target attribute set to which this instruction is provisionally boundStructuredQName
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 expressionstatic java.util.List<UseAttributeSet>
makeUseAttributeSetInstructions(StructuredQName[] targets, StyleElement instruction)
Make a 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 elementstatic 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 elementjava.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.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, dispatchTailCall, dynamicError, effectiveBooleanValue, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, 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, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
-
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 setstreamable
- true if the attribute set is streamable
-
-
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 classInstruction
- 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 attributeinstruction
- 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 a 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 attributeinstruction
- 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 interfaceComponentInvocation
- 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 interfaceComponentInvocation
- 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 interfaceComponentInvocation
- 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 interfaceComponentInvocation
- 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.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 classInstruction
- 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 classExpression
- Parameters:
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 toType.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 classExpression
- 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 classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- 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 classInstruction
- 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 classExpression
- 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
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classInstruction
- 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 interfaceExportAgent
- Specified by:
export
in classExpression
- 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 classExpression
- 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
protected int computeHashCode()
Compute a hashcode- Overrides:
computeHashCode
in classExpression
- 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 classExpression
- 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
-
getElaborator
public Elaborator getElaborator()
Description copied from class:Expression
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-
-