net.sf.saxon.instruct

Class SimpleNodeConstructor

public abstract class SimpleNodeConstructor extends Instruction

Common superclass for XSLT instructions whose content template produces a text value: xsl:attribute, xsl:comment, xsl:processing-instruction, xsl:namespace, and xsl:text
Field Summary
protected Expressionselect
Constructor Summary
SimpleNodeConstructor()
Method Summary
protected StringcheckContent(String data, XPathContext context)
Check the content of the node, and adjust it if necessary.
intcomputeSpecialProperties()
Get the static properties of this expression (other than its type).
booleancreatesNewNodes()
Determine whether this instruction creates new nodes.
voiddisplay(int level, NamePool pool, PrintStream out)
Display this instruction as an expression, for diagnostics
ItemevaluateItem(XPathContext context)
Evaluate as an expression.
protected intevaluateNameCode(XPathContext context)
CharSequenceexpandChildren(XPathContext context)
Expand the stylesheet elements subordinate to this one, returning the result as a string.
ExpressiongetSelect()
SequenceIteratoriterate(XPathContext context)
IteratoriterateSubExpressions()
abstract voidlocalTypeCheck(StaticContext env, ItemType contextItemType)
Expressionoptimize(Optimizer opt, StaticContext env, ItemType contextItemType)
protected voidpromoteInst(PromotionOffer offer)
Offer promotion for subexpressions.
voidsetSelect(Expression select, Configuration config)
Expressionsimplify(StaticContext env)
ExpressiontypeCheck(StaticContext env, ItemType contextItemType)
The typeCheck() method is called in XQuery, where node constructors are implemented as Expressions.

Field Detail

select

protected Expression select

Constructor Detail

SimpleNodeConstructor

public SimpleNodeConstructor()

Method Detail

checkContent

protected String checkContent(String data, XPathContext context)
Check the content of the node, and adjust it if necessary. The checks depend on the node kind.

Parameters: data the supplied content context the dynamic context

Returns: the original content, unless adjustments are needed

Throws: DynamicError if the content is invalid

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.

Returns: a set of flags indicating static properties of this expression

createsNewNodes

public final boolean createsNewNodes()
Determine whether this instruction creates new nodes. This implementation returns true.

display

public void display(int level, NamePool pool, PrintStream out)
Display this instruction as an expression, for diagnostics

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

evaluateNameCode

protected int evaluateNameCode(XPathContext context)

expandChildren

public CharSequence expandChildren(XPathContext context)
Expand the stylesheet elements subordinate to this one, returning the result as a string. The expansion must not generate any element or attribute nodes.

Parameters: context The dynamic context for the transformation

getSelect

public Expression getSelect()

iterate

public SequenceIterator iterate(XPathContext context)

iterateSubExpressions

public Iterator iterateSubExpressions()

localTypeCheck

public abstract void localTypeCheck(StaticContext env, ItemType contextItemType)

optimize

public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)

promoteInst

protected void promoteInst(PromotionOffer offer)
Offer promotion for subexpressions. The offer will be accepted if the subexpression is not dependent on the factors (e.g. the context item) identified in the PromotionOffer. By default the offer is not accepted - this is appropriate in the case of simple expressions such as constant values and variable references where promotion would give no performance advantage. This method is always called at compile time.

Parameters: offer details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expression

Throws: XPathException if any error is detected

setSelect

public void setSelect(Expression select, Configuration config)

simplify

public Expression simplify(StaticContext env)

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)
The typeCheck() method is called in XQuery, where node constructors are implemented as Expressions. In this case the required type for the select expression is a single string.

Parameters: env The static context for the query

Returns: the rewritten expression

Throws: XPathException if any static errors are found in this expression or any of its children