Package net.sf.saxon.expr.instruct
Class SimpleNodeConstructor
java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.instruct.Instruction
net.sf.saxon.expr.instruct.SimpleNodeConstructor
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
- Direct Known Subclasses:
AttributeCreator
,Comment
,NamespaceConstructor
,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, and their XQuery equivalents
-
Field Summary
FieldsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
Ask whether common subexpressions found in the operands of this expression can be extracted and evaluated outside the expression itself.boolean
Ask whether it is guaranteed that every item in the result of this instruction is a newly created nodecheckContent
(UnicodeString data, XPathContext context) Check the content of the node, and adjust it if necessary.protected int
Get the cardinality of the sequence returned by evaluating this instructionprotected int
Get the static properties of this expression (other than its type).evaluateItem
(XPathContext context) Evaluate as an expression.evaluateNodeName
(XPathContext context) Run-time method to compute the name of the node being constructed.Get the select expression, that is the expression that computes the content of the constructed node.Get the select operand, that is the operand that wraps the select expressionGet the (partial) name of a class that supports streaming of this kind of expressionboolean
isLocal()
iterate
(XPathContext context) Return an Iterator to iterate over the values of a sequence.abstract void
localTypeCheck
(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Method to perform type-checking specific to the kind of instructionfinal boolean
Ask whether this instruction creates new nodes.operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.optimize
(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Perform optimisation of an expression and its subexpressions.abstract void
processValue
(UnicodeString value, Outputter output, XPathContext context) Process the value of the node, to create the new node.void
setSelect
(Expression select) Set the select expression: the value of this expression determines the string-value of the nodetypeCheck
(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) The typeCheck() method is called in XQuery, where node constructors are implemented as Expressions.Methods inherited from class net.sf.saxon.expr.instruct.Instruction
assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, getExpressionName, getImplementationMethod, getInstructionNameCode, getItemType, getNetCost, getSourceLocator, isInstruction, isXSLT, process, someOperandCreatesNewNodes
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, copy, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, explain, export, getCardinality, getConfiguration, getCost, getDependencies, getElaborator, getEvaluationMethod, getExtraProperty, getIntegerBounds, getIntrinsicDependencies, 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
-
Field Details
-
selectOp
-
-
Constructor Details
-
SimpleNodeConstructor
public SimpleNodeConstructor()Default constructor used by subclasses
-
-
Method Details
-
setSelect
Set the select expression: the value of this expression determines the string-value of the node- Parameters:
select
- the expression that computes the string value of the node
-
getSelect
Get the select expression, that is the expression that computes the content of the constructed node. Note that this may correspond either to a select attribute or a contained sequence constructor in the case of XSLT; and in XQuery it corresponds to whatever expression is contained in the node constructpr.- Returns:
- the expression used to compute the content of the node.
-
getSelectOp
Get the select operand, that is the operand that wraps the select expression- Returns:
- the select 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
-
mayCreateNewNodes
public final boolean mayCreateNewNodes()Ask whether this instruction creates new nodes. This implementation returns true.- Overrides:
mayCreateNewNodes
in classInstruction
- Returns:
- true if the instruction creates new nodes under some input conditions (or if it can't be proved that it doesn't)
-
alwaysCreatesNewNodes
public boolean alwaysCreatesNewNodes()Ask whether it is guaranteed that every item in the result of this instruction is a newly created node- Overrides:
alwaysCreatesNewNodes
in classInstruction
- Returns:
- true if result of the instruction is always either an empty sequence or a sequence consisting entirely of newly created nodes
-
computeCardinality
protected int computeCardinality()Get the cardinality of the sequence returned by evaluating this instruction- Overrides:
computeCardinality
in classInstruction
- Returns:
- the static cardinality
-
computeSpecialProperties
protected 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
-
allowExtractingCommonSubexpressions
public boolean allowExtractingCommonSubexpressions()Ask whether common subexpressions found in the operands of this expression can be extracted and evaluated outside the expression itself. The result is irrelevant in the case of operands evaluated with a different focus, which will never be extracted in this way, even if they have no focus dependency.- Overrides:
allowExtractingCommonSubexpressions
in classExpression
- Returns:
- false for this kind of expression
-
localTypeCheck
public abstract void localTypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException Method to perform type-checking specific to the kind of instruction- Parameters:
visitor
- an expression visitorcontextItemType
- the static type of the context item- Throws:
XPathException
- if a type error is detected
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException 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. param visitor an expression visitor- Overrides:
typeCheck
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- information about the dynamic context- Returns:
- the rewritten expression
- Throws:
XPathException
- if any static errors are found in this expression or any of its children
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException Description copied from class: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.
- 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)
-
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
-
processValue
public abstract void processValue(UnicodeString value, Outputter output, XPathContext context) throws XPathException Process the value of the node, to create the new node.- Parameters:
value
- the string value of the new nodeoutput
- the destination for the resultcontext
- the dynamic evaluation context- Throws:
XPathException
- if a dynamic error occurs
-
evaluateItem
Evaluate as an expression.- 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:
XPathException
- if the content is invalid
-
evaluateNodeName
Run-time method to compute the name of the node being constructed. This is overridden for nodes that have a name. The default implementation returns -1, which is suitable for unnamed nodes such as comments- Parameters:
context
- the XPath dynamic evaluation context- Returns:
- the name pool nameCode identifying the name of the constructed node
- Throws:
XPathException
- if any failure occurs
-
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.- 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
-
isLocal
public boolean isLocal()
-