Package net.sf.saxon.instruct
Class SimpleNodeConstructor
java.lang.Object
net.sf.saxon.expr.ComputedExpression
net.sf.saxon.instruct.Instruction
net.sf.saxon.instruct.SimpleNodeConstructor
- All Implemented Interfaces:
Serializable
,SourceLocator
,Container
,Expression
,TailCallReturner
,InstructionInfoProvider
- Direct Known Subclasses:
Attribute
,Comment
,FixedAttribute
,Namespace
,ProcessingInstruction
,ValueOf
Common superclass for XSLT instructions whose content template produces a text
value: xsl:attribute, xsl:comment, xsl:processing-instruction, xsl:namespace,
and xsl:text
- See Also:
-
Field Summary
FieldsFields inherited from class net.sf.saxon.expr.ComputedExpression
locationId, staticProperties
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
checkContent
(String data, XPathContext context) Check the content of the node, and adjust it if necessary.int
Get the static properties of this expression (other than its type).final boolean
Determine whether this instruction creates new nodes.void
display
(int level, PrintStream out, Configuration config) Display this instruction as an expression, for diagnosticsevaluateItem
(XPathContext context) Evaluate as an expression.int
evaluateNameCode
(XPathContext context) expandChildren
(XPathContext context) Expand the stylesheet elements subordinate to this one, returning the result as a string.iterate
(XPathContext context) Return an Iterator to iterate over the values of a sequence.Get the immediate sub-expressions of this expression.abstract void
localTypeCheck
(StaticContext env, ItemType contextItemType) optimize
(Optimizer opt, StaticContext env, ItemType contextItemType) Perform optimisation of an expression and its subexpressions.protected void
promoteInst
(PromotionOffer offer) Offer promotion for subexpressions.boolean
replaceSubExpression
(Expression original, Expression replacement) Replace one subexpression by a replacement subexpressionvoid
setSelect
(Expression select, Configuration config) simplify
(StaticContext env) Simplify an expression.typeCheck
(StaticContext env, ItemType contextItemType) The typeCheck() method is called in XQuery, where node constructors are implemented as Expressions.Methods inherited from class net.sf.saxon.instruct.Instruction
appendItem, assembleParams, assembleTunnelParams, computeCardinality, dynamicError, evaluateAsString, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getItemType, getSourceLocator, isXSLT, process, processLeavingTail, promote
Methods inherited from class net.sf.saxon.expr.ComputedExpression
adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, getCardinality, getColumnNumber, getConstructType, getDependencies, getExecutable, getHostLanguage, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, suppressValidation, typeError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.xml.transform.SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
-
Field Details
-
select
-
-
Constructor Details
-
SimpleNodeConstructor
public SimpleNodeConstructor()
-
-
Method Details
-
setSelect
- Throws:
StaticError
-
getSelect
-
createsNewNodes
public final boolean createsNewNodes()Determine whether this instruction creates new nodes. This implementation returns true.- Overrides:
createsNewNodes
in classInstruction
-
simplify
Description copied from class:Instruction
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.- Specified by:
simplify
in interfaceExpression
- Specified by:
simplify
in classInstruction
- Parameters:
env
- the static context- Returns:
- the simplified expression
- Throws:
XPathException
- if an error is discovered during expression rewriting
-
computeSpecialProperties
public int computeSpecialProperties()Get the static properties of this expression (other than its type). The result is bit-signficant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.- Overrides:
computeSpecialProperties
in classInstruction
- Returns:
- a set of flags indicating static properties of this expression
-
localTypeCheck
public abstract void localTypeCheck(StaticContext env, ItemType contextItemType) throws XPathException - Throws:
XPathException
-
typeCheck
The typeCheck() method is called in XQuery, where node constructors are implemented as Expressions. In this case the required type for the select expression is a single string.- Parameters:
env
- The static context for the querycontextItemType
- 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 rewritten expression
- Throws:
XPathException
- if any static errors are found in this expression or any of its children
-
optimize
public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType) throws XPathException Description copied from interface:Expression
Perform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.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.
- Parameters:
opt
- the optimizer in use. This provides access to supporting functions; it also allows different optimization strategies to be used in different circumstances.env
- the static context of the expressioncontextItemType
- 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
-
iterateSubExpressions
Description copied from class:ComputedExpression
Get the immediate sub-expressions of this expression. Default implementation returns a zero-length array, appropriate for an expression that has no sub-expressions.- Specified by:
iterateSubExpressions
in interfaceExpression
- Overrides:
iterateSubExpressions
in classComputedExpression
- Returns:
- an iterator containing the sub-expressions of this expression
-
replaceSubExpression
Replace one subexpression by a replacement subexpression- Specified by:
replaceSubExpression
in interfaceContainer
- Overrides:
replaceSubExpression
in classComputedExpression
- Parameters:
original
- the original subexpressionreplacement
- the replacement subexpression- Returns:
- true if the original subexpression is found
-
expandChildren
Expand the stylesheet elements subordinate to this one, returning the result as a string. The expansion must not generate any element or attribute nodes.- Parameters:
context
- The dynamic context for the transformation- Throws:
XPathException
-
evaluateItem
Evaluate as an expression. We rely on the fact that when these instructions are generated by XQuery, there will always be a valueExpression to evaluate the content- Specified by:
evaluateItem
in interfaceExpression
- Overrides:
evaluateItem
in classInstruction
- Parameters:
context
- 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
-
checkContent
Check the content of the node, and adjust it if necessary. The checks depend on the node kind.- Parameters:
data
- the supplied contentcontext
- the dynamic context- Returns:
- the original content, unless adjustments are needed
- Throws:
DynamicError
- if the content is invalid
-
evaluateNameCode
- Throws:
XPathException
-
iterate
Description copied from class:Instruction
Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.- Specified by:
iterate
in interfaceExpression
- Overrides:
iterate
in classInstruction
- Parameters:
context
- 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
-
display
Display this instruction as an expression, for diagnostics- Parameters:
level
- indentation level for this expressionout
- Output destinationconfig
-
-
promoteInst
Offer promotion for subexpressions. The offer will be accepted if the subexpression is not dependent on the factors (e.g. the context item) identified in the PromotionOffer. By default the offer is not accepted - this is appropriate in the case of simple expressions such as constant values and variable references where promotion would give no performance advantage. This method is always called at compile time.- Overrides:
promoteInst
in classInstruction
- Parameters:
offer
- details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expression- Throws:
XPathException
- if any error is detected
-