Package net.sf.saxon.expr.instruct
Class SourceDocument
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.instruct.Instruction
-
- net.sf.saxon.expr.instruct.SourceDocument
-
- All Implemented Interfaces:
ExportAgent
,TailCallReturner
,Locatable
,IdentityComparable
,Traceable
- Direct Known Subclasses:
StreamInstr
public class SourceDocument extends Instruction
Non-streamable implementation of the xsl:source-document instruction
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<? extends Accumulator>
accumulators
protected Operand
bodyOp
protected Operand
hrefOp
protected ParseOptions
parseOptions
-
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 SourceDocument(Expression hrefExp, Expression body, ParseOptions options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowExtractingCommonSubexpressions()
Ask whether common subexpressions found in the operands of this expression can be extracted and evaluated outside the expression itself.int
computeDependencies()
Compute the dependencies of an expression, as the union of the dependencies of its subexpressions.int
computeSpecialProperties()
Get the static properties of this expression (other than its type).Expression
copy(RebindingMap rebindings)
Copy an expression.void
export(ExpressionPresenter out)
Diagnostic print of expression structure.Expression
getBody()
java.lang.String
getExportTag()
java.lang.String
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.Expression
getHref()
boolean
mayCreateNewNodes()
Determine whether this instruction creates new nodes.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
push(Outputter output, XPathContext context)
Evaluate the instruction in push modevoid
setBody(Expression body)
void
setHref(Expression href)
void
setUsedAccumulators(java.util.Set<? extends Accumulator> 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, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionNameCode, getItemType, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, process, someOperandCreatesNewNodes
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeHashCode, computeStaticProperties, dynamicError, effectiveBooleanValue, equals, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, 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
-
-
-
-
Field Detail
-
hrefOp
protected Operand hrefOp
-
bodyOp
protected Operand bodyOp
-
parseOptions
protected ParseOptions parseOptions
-
accumulators
protected java.util.Set<? extends Accumulator> accumulators
-
-
Constructor Detail
-
SourceDocument
public SourceDocument(Expression hrefExp, Expression body, ParseOptions options)
-
-
Method Detail
-
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.
-
getExportTag
public java.lang.String getExportTag()
-
getHref
public Expression getHref()
-
setHref
public void setHref(Expression href)
-
getBody
public Expression getBody()
-
setBody
public void setBody(Expression body)
-
setUsedAccumulators
public void setUsedAccumulators(java.util.Set<? extends Accumulator> used)
-
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 classInstruction
- Returns:
- an iterator containing the sub-expressions 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
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Perform type checking of an expression and its subexpressions. This is the second phase of static optimization.- Overrides:
typeCheck
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- 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)
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
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)
-
mayCreateNewNodes
public boolean mayCreateNewNodes()
Determine whether this instruction creates new nodes. This implementation returns a default value of false- Overrides:
mayCreateNewNodes
in classInstruction
- Returns:
- true if the instruction creates new nodes (or if it can't be proved that it doesn't)
-
computeDependencies
public int computeDependencies()
Compute the dependencies of an expression, as the union of the dependencies of its subexpressions. (This is overridden for path expressions and filter expressions, where the dependencies of a subexpression are not all propogated). This method should be called only once, to compute the dependencies; after that, getDependencies should be used.- Overrides:
computeDependencies
in classExpression
- Returns:
- the depencies, as a bit-mask
-
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
-
export
public void export(ExpressionPresenter out) throws XPathException
Diagnostic print 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.
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- variables that need to be re-bound- Returns:
- the copy of the original expression
-
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 interfaceTailCallReturner
- Specified by:
processLeavingTail
in classInstruction
- Parameters:
output
- the destination for the resultcontext
- 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
-
push
public void push(Outputter output, XPathContext context) throws XPathException
Evaluate the instruction in push mode- Parameters:
context
- the evaluation context- Throws:
XPathException
- in the event of a failureQuitParsingException
- if there was an early exit, that is, if the instruction was evaluated without reading the input to completion
-
-