net.sf.saxon.instruct

Class DocumentInstr

public class DocumentInstr extends ParentNodeConstructor

An instruction to create a document node. This corresponds to the xsl:document-node instruction in XSLT. It is also used to support the document node constructor expression in XQuery, and is generated implicitly within an xsl:variable that constructs a temporary tree.

Conceptually it represents an XSLT instruction xsl:document-node, with no attributes, whose content is a complex content constructor for the children of the document node.

Constructor Summary
DocumentInstr(boolean textOnly, String constantText, String baseURI)
Create a document constructor instruction
Method Summary
protected voidcheckContentSequence(StaticContext env)
Check statically that the sequence of child instructions doesn't violate any obvious constraints on the content of the node
protected static voidcheckContentSequence(StaticContext env, Expression content, int validation, SchemaType type)
Expressioncopy()
Copy an expression.
ItemevaluateItem(XPathContext context)
Evaluate as an expression.
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
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 diagnostic and tracing purposes (the string "document-constructor")
ItemTypegetItemType(TypeHierarchy th)
Get the item type
ExpressiongetStringValueExpression(StaticContext env)
In the case of a text-only instruction (xsl:variable containing a text node or one or more xsl:value-of instructions), return an expression that evaluates to the textual content as an instance of xs:untypedAtomic
booleanisTextOnly()
Determine whether this is a "text only" document: essentially, an XSLT xsl:variable that contains a single text node or xsl:value-of instruction.
EventIteratoriterateEvents(XPathContext context)
TailCallprocessLeavingTail(XPathContext context)
voidprocessLeft(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the first half of the instruction (to start a new document or element)
voidprocessRight(Stack<XPathContext> contextStack, Stack state)
In streaming mode, proecss the right half of the instruction (to end a new document or element)
Expressionsimplify(ExpressionVisitor visitor)
Simplify an expression.

Constructor Detail

DocumentInstr

public DocumentInstr(boolean textOnly, String constantText, String baseURI)
Create a document constructor instruction

Parameters: textOnly true if the content contains text nodes only constantText if the content contains text nodes only and the text is known at compile time, supplies the textual content baseURI the base URI of the instruction

Method Detail

checkContentSequence

protected void checkContentSequence(StaticContext env)
Check statically that the sequence of child instructions doesn't violate any obvious constraints on the content of the node

Parameters: env the static context

Throws: XPathException

checkContentSequence

protected static void checkContentSequence(StaticContext env, Expression content, int validation, SchemaType type)

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.

explain

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

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 prefered. For instructions this is the process() method.

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes (the string "document-constructor")

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type

Parameters: th The TypeHierarchy

Returns: the in

getStringValueExpression

public Expression getStringValueExpression(StaticContext env)
In the case of a text-only instruction (xsl:variable containing a text node or one or more xsl:value-of instructions), return an expression that evaluates to the textual content as an instance of xs:untypedAtomic

Parameters: env the static evaluation context

Returns: an expression that evaluates to the textual content

isTextOnly

public boolean isTextOnly()
Determine whether this is a "text only" document: essentially, an XSLT xsl:variable that contains a single text node or xsl:value-of instruction.

Returns: true if this is a text-only document

iterateEvents

public EventIterator iterateEvents(XPathContext context)

processLeavingTail

public TailCall processLeavingTail(XPathContext context)

processLeft

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

Parameters: contextStack state a stack on which the instruction can save state information for use during the corresponding

processRight

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

Parameters: contextStack state a stack on which the instruction can save state information for use during the corresponding

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