net.sf.saxon.instruct

Class Copy

public class Copy extends ElementCreator

Handler for xsl:copy elements in stylesheet.
Constructor Summary
Copy(boolean copyNamespaces, boolean inheritNamespaces, SchemaType schemaType, int validation)
Create a shallow copy instruction
Method Summary
Expressioncopy()
Copy an expression.
ItemevaluateItem(XPathContext context)
Evaluate as an expression.
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
int[]getActiveNamespaces()
Callback to get a list of the intrinsic namespaces that need to be generated for the element.
intgetInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes
intgetIntrinsicDependencies()
Determine which aspects of the context the expression depends on.
ItemTypegetItemType(TypeHierarchy th)
Get the item type of the result of this instruction.
intgetNameCode(XPathContext context)
Callback from ElementCreator when constructing an element
StringgetNewBaseURI(XPathContext context)
Get the base URI of a copied element node (the base URI is retained in the new copy)
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
protected voidoutputNamespaceNodes(XPathContext context, Receiver receiver, int nameCode)
Callback to output namespace nodes for the new element.
TailCallprocessLeavingTail(XPathContext context)
voidprocessLeft(Stack<XPathContext> contextStack, Stack state)
Process the first half of the instruction in streaming mode
voidprocessRight(Stack<XPathContext> contextStack, Stack state)
Process the second half of the instruction in streaming mode
Expressionsimplify(ExpressionVisitor visitor)
Simplify an expression.
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Constructor Detail

Copy

public Copy(boolean copyNamespaces, boolean inheritNamespaces, SchemaType schemaType, int validation)
Create a shallow copy instruction

Parameters: copyNamespaces true if namespace nodes are to be copied when copying an element inheritNamespaces true if child elements are to inherit the namespace nodes of their parent schemaType the Schema type against which the content is to be validated validation the schema validation mode

Method Detail

copy

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

Returns: the copy of the original expression

evaluateItem

public Item evaluateItem(XPathContext context)
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

explain

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

getActiveNamespaces

public int[] getActiveNamespaces()
Callback to get a list of the intrinsic namespaces that need to be generated for the element. The result is an array of namespace codes, the codes either occupy the whole array or are terminated by a -1 entry. A result of null is equivalent to a zero-length array.

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes

getIntrinsicDependencies

public int getIntrinsicDependencies()
Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as XPathContext.VARIABLES and XPathContext.CURRENT_NODE. The default implementation combines the intrinsic dependencies of this expression with the dependencies of the subexpressions, computed recursively. This is overridden for expressions such as FilterExpression where a subexpression's dependencies are not necessarily inherited by the parent expression.

Returns: a set of bit-significant flags identifying the dependencies of the expression

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type of the result of this instruction.

Parameters: th the type hierarchy cache

Returns: The context item type.

getNameCode

public int getNameCode(XPathContext context)
Callback from ElementCreator when constructing an element

Parameters: context XPath dynamic evaluation context

Returns: the namecode of the element to be constructed

Throws: XPathException

getNewBaseURI

public String getNewBaseURI(XPathContext context)
Get the base URI of a copied element node (the base URI is retained in the new copy)

Parameters: context XPath dynamic evaluation context

Returns: the base URI

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)

outputNamespaceNodes

protected void outputNamespaceNodes(XPathContext context, Receiver receiver, int nameCode)
Callback to output namespace nodes for the new element.

Parameters: context The execution context receiver the Receiver where the namespace nodes are to be written nameCode

Throws: XPathException

processLeavingTail

public TailCall processLeavingTail(XPathContext context)

processLeft

public void processLeft(Stack<XPathContext> contextStack, Stack state)
Process the first half of the instruction in streaming mode

processRight

public void processRight(Stack<XPathContext> contextStack, Stack state)
Process the second half of the instruction in streaming mode

simplify

public Expression simplify(ExpressionVisitor visitor)
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.

Parameters: visitor an expression visitor

Returns: the simplified expression

Throws: net.sf.saxon.trans.XPathException if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)