net.sf.saxon.instruct

Class CopyOf

public class CopyOf extends Instruction implements DivisibleInstruction

An xsl:copy-of element in the stylesheet.
Constructor Summary
CopyOf(Expression select, boolean copyNamespaces, int validation, SchemaType schemaType, boolean rejectDuplicateAttributes)
Create an xsl:copy-of instruction (also used in XQuery for implicit copying)
Method Summary
Expressioncopy()
Copy an expression.
static voidcopyAttribute(NodeInfo source, SchemaType schemaType, int validation, Instruction instruction, XPathContext context, boolean rejectDuplicates)
Method shared by xsl:copy and xsl:copy-of to copy an attribute node
booleancreatesNewNodes()
Determine whether this instruction creates new nodes.
ItemevaluateItem(XPathContext context)
Return the first item if there is one, or null if not
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
intgetCardinality()
intgetDependencies()
intgetImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
intgetInstructionNameCode()
Get the name of this instruction, for diagnostics and tracing
ItemTypegetItemType(TypeHierarchy th)
SchemaTypegetSchemaType()
Get the schema type to be used for validation
ExpressiongetSelectExpression()
Get the expression that selects the nodes to be copied
intgetValidationMode()
Get the validation mode
booleanisCopyForUpdate()
Ask whether this instruction is creating a copy for the purpose of updating (XQuery transform expression)
booleanisCopyNamespaces()
Determine whether namespaces are to be copied or not
booleanisDocumentOrElementRequired()
Test whether this expression requires a document or element node
SequenceIteratoriterate(XPathContext context)
Iterator<Expression>iterateSubExpressions()
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
TailCallprocessLeavingTail(XPathContext context)
Process this xsl:copy-of instruction
voidprocessLeft(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the first half of the instruction (for example, to start a new document or element)
voidprocessRight(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the right half of the instruction (for example, to end a new document or element)
protected voidpromoteInst(PromotionOffer offer)
booleanreplaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression
voidsetCopyForUpdate(boolean forUpdate)
Set whether this instruction is creating a copy for the purpose of updating (XQuery transform expression)
voidsetCopyLineNumbers(boolean copy)
Set whether line numbers are to be copied from the source to the result.
voidsetReadOnce(boolean b)
Set the "saxon:read-once" optimization mode
voidsetRequireDocumentOrElement(boolean requireDocumentOrElement)
For XQuery, the operand (select) must be a single element or document node.
voidsetStaticBaseUri(String base)
Set the static base URI of the xsl:copy-of instruction
Expressionsimplify(ExpressionVisitor visitor)
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Constructor Detail

CopyOf

public CopyOf(Expression select, boolean copyNamespaces, int validation, SchemaType schemaType, boolean rejectDuplicateAttributes)
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 rejectDuplicateAttributes true if duplicate attributes are to be rejected (XQuery). False if duplicates are handled by discarding all but the first (XSLT).

Method Detail

copy

public Expression copy()
Copy an expression. This makes a deep copy.

Returns: the copy of the original expression

copyAttribute

static void copyAttribute(NodeInfo source, SchemaType schemaType, int validation, Instruction instruction, XPathContext context, boolean rejectDuplicates)
Method shared by xsl:copy and xsl:copy-of to copy an attribute node

Parameters: source the node to be copied schemaType the simple type against which the value is to be validated, if any validation one of preserve, strip, strict, lax instruction the calling instruction, used for diagnostics context the dynamic context rejectDuplicates true if duplicate attributes with the same name are disallowed (XQuery)

Throws: XPathException

createsNewNodes

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

evaluateItem

public Item evaluateItem(XPathContext context)
Return the first item if there is one, or null if not

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.

getCardinality

public int getCardinality()

getDependencies

public int getDependencies()

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.

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction, for diagnostics and tracing

getItemType

public ItemType getItemType(TypeHierarchy th)

getSchemaType

public SchemaType getSchemaType()
Get the schema type to be used for validation

Returns: the schema type, or null if not validating against a type

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

isCopyForUpdate

public boolean isCopyForUpdate()
Ask whether this instruction is creating a copy for the purpose of updating (XQuery transform expression)

Returns: true if this copy is being created to support an update

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)

iterateSubExpressions

public Iterator<Expression> iterateSubExpressions()

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
Process this xsl:copy-of instruction

Parameters: context the dynamic context for the transformation

Returns: null - this implementation of the method never returns a TailCall

processLeft

public void processLeft(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the first half of the instruction (for example, to start a new document or element)

Parameters: contextStack state a stack on which the instruction can save state information during the call on processLeft()

processRight

public void processRight(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the right half of the instruction (for example, to end a new document or element)

Parameters: contextStack state a stack on which the instruction can save state information during the call on processLeft()

promoteInst

protected void promoteInst(PromotionOffer offer)

replaceSubExpression

public boolean replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression

Parameters: original the original subexpression replacement the replacement subexpression

Returns: true if the original subexpression is found

setCopyForUpdate

public void setCopyForUpdate(boolean forUpdate)
Set whether this instruction is creating a copy for the purpose of updating (XQuery transform expression)

Parameters: forUpdate true if this copy is being created to support an update

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

setStaticBaseUri

public void setStaticBaseUri(String base)
Set the static base URI of the xsl:copy-of instruction

Parameters: base the static base URI

simplify

public Expression simplify(ExpressionVisitor visitor)

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)