net.sf.saxon.instruct

Class CopyOf

Implemented Interfaces:
SourceLocator, EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator, TailCallReturner

public class CopyOf
extends Instruction

An xsl:copy-of element in the stylesheet.

Field Summary

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

EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD, locationId, staticProperties

Constructor Summary

CopyOf(Expression select, boolean copyNamespaces, int validation, SchemaType schemaType, boolean rejectDuplicatAttributes)
Create an xsl:copy-of instruction (also used in XQuery for implicit copying)

Method Summary

Expression
copy()
Copy an expression.
boolean
createsNewNodes()
Determine whether this instruction creates new nodes.
Item
evaluateItem(XPathContext context)
Return the first item if there is one, or null if not
void
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
int
getCardinality()
int
getDependencies()
int
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
int
getInstructionNameCode()
Get the name of this instruction, for diagnostics and tracing
ItemType
getItemType(TypeHierarchy th)
Expression
getSelectExpression()
Get the expression that selects the nodes to be copied
int
getValidationMode()
Get the validation mode
boolean
isCopyNamespaces()
Determine whether namespaces are to be copied or not
boolean
isDocumentOrElementRequired()
Test whether this expression requires a document or element node
SequenceIterator
iterate(XPathContext context)
Iterator
iterateSubExpressions()
Expression
optimize(ExpressionVisitor visitor, ItemType contextItemType)
TailCall
processLeavingTail(XPathContext context)
Process this xsl:copy-of instruction
protected void
promoteInst(PromotionOffer offer)
boolean
replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression
void
setCopyLineNumbers(boolean copy)
Set whether line numbers are to be copied from the source to the result.
void
setReadOnce(boolean b)
Set the "saxon:read-once" optimization mode
void
setRequireDocumentOrElement(boolean requireDocumentOrElement)
For XQuery, the operand (select) must be a single element or document node.
Expression
simplify(ExpressionVisitor visitor)
Expression
typeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Methods inherited from class net.sf.saxon.instruct.Instruction

assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, createsNewNodes, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getItemType, getSourceLocator, isXSLT, iterate, process, processLeavingTail, promote, promoteInst, simplify

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

addToPathMap, adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, explain, findParentOf, getCardinality, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getItemType, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterate, iterateEvents, iterateSubExpressions, markTailFunctionCalls, optimize, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, toString, typeCheck, typeError

Constructor Details

CopyOf

public CopyOf(Expression select,
              boolean copyNamespaces,
              int validation,
              SchemaType schemaType,
              boolean rejectDuplicatAttributes)
Create an xsl:copy-of instruction (also used in XQuery for implicit copying)
Parameters:
select - expression that selects the nodes to be copied
copyNamespaces - true if namespaces are to be copied
validation - validation mode for the result tree
schemaType - schema type for validating the result tree
rejectDuplicatAttributes - true if duplicat attributes are to be rejected (XQuery). False if duplicates are handled by discarding all but the first (XSLT).

Method Details

copy

public Expression copy()
Copy an expression. This makes a deep copy.
Overrides:
copy in interface Expression
Returns:
the copy of the original expression

createsNewNodes

public final boolean createsNewNodes()
Determine whether this instruction creates new nodes. The result depends on the type of the select expression.
Overrides:
createsNewNodes in interface Instruction

evaluateItem

public Item evaluateItem(XPathContext context)
            throws XPathException
Return the first item if there is one, or null if not
Specified by:
evaluateItem in interface EvaluableItem
Overrides:
evaluateItem in interface Instruction
Parameters:
context - the XPath dynamic context
Returns:
the result of evaluating the instruction
Throws:
XPathException -

explain

public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
Overrides:
explain in interface Expression

getCardinality

public int getCardinality()
Overrides:
getCardinality in interface Expression

getDependencies

public int getDependencies()
Overrides:
getDependencies in interface Expression

getImplementationMethod

public int getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided. This implementation provides both iterate() and process() methods natively.
Overrides:
getImplementationMethod in interface Instruction

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction, for diagnostics and tracing
Overrides:
getInstructionNameCode in interface Instruction

getItemType

public ItemType getItemType(TypeHierarchy th)
Overrides:
getItemType in interface Instruction

getSelectExpression

public Expression getSelectExpression()
Get the expression that selects the nodes to be copied
Returns:
the select expression

getValidationMode

public int getValidationMode()
Get the validation mode
Returns:
the validation mode

isCopyNamespaces

public boolean isCopyNamespaces()
Determine whether namespaces are to be copied or not
Returns:
true if namespaces are to be copied (the default)

isDocumentOrElementRequired

public boolean isDocumentOrElementRequired()
Test whether this expression requires a document or element node
Returns:
true if this expression requires the value of the argument to be a document or element node, false if there is no such requirement

iterate

public SequenceIterator iterate(XPathContext context)
            throws XPathException
Specified by:
iterate in interface SequenceIterable
Overrides:
iterate in interface Instruction

iterateSubExpressions

public Iterator iterateSubExpressions()
Overrides:
iterateSubExpressions in interface Expression

optimize

public Expression optimize(ExpressionVisitor visitor,
                           ItemType contextItemType)
            throws XPathException
Overrides:
optimize in interface Expression

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
            throws XPathException
Process this xsl:copy-of instruction
Specified by:
processLeavingTail in interface TailCallReturner
Overrides:
processLeavingTail in interface Instruction
Parameters:
context - the dynamic context for the transformation
Returns:
null - this implementation of the method never returns a TailCall

promoteInst

protected void promoteInst(PromotionOffer offer)
            throws XPathException
Overrides:
promoteInst in interface Instruction

replaceSubExpression

public boolean replaceSubExpression(Expression original,
                                    Expression replacement)
Replace one subexpression by a replacement subexpression
Overrides:
replaceSubExpression in interface Expression
Parameters:
original - the original subexpression
replacement - the replacement subexpression
Returns:
true if the original subexpression is found

setCopyLineNumbers

public void setCopyLineNumbers(boolean copy)
Set whether line numbers are to be copied from the source to the result. Default is false.
Parameters:
copy - true if line numbers are to be copied

setReadOnce

public void setReadOnce(boolean b)
Set the "saxon:read-once" optimization mode
Parameters:
b - true to enable the optimization

setRequireDocumentOrElement

public void setRequireDocumentOrElement(boolean requireDocumentOrElement)
For XQuery, the operand (select) must be a single element or document node.
Parameters:
requireDocumentOrElement - true if the argument must be a single element or document node

simplify

public Expression simplify(ExpressionVisitor visitor)
            throws XPathException
Overrides:
simplify in interface Instruction

typeCheck

public Expression typeCheck(ExpressionVisitor visitor,
                            ItemType contextItemType)
            throws XPathException
Overrides:
typeCheck in interface Expression