net.sf.saxon.instruct

Class SimpleContentConstructor

public class SimpleContentConstructor extends ComputedExpression

This class implements the rules for an XSLT simple content constructor, which are used in constructing the string value of an attribute node, text node, comment node, etc, from the value of the select expression or the contained sequence constructor.
Field Summary
booleanisAtomic
booleanisSingleton
Expressionselect
Expressionseparator
Constructor Summary
SimpleContentConstructor(Expression select, Expression separator)
Method Summary
protected intcomputeCardinality()
Compute the cardinality of the result of the expression.
voiddisplay(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure.
ItemevaluateItem(XPathContext context)
Evaluate an expression as a single item.
intgetImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the expression, if possible.
IteratoriterateSubExpressions()
Get the immediate sub-expressions of this expression.
Expressionoptimize(Optimizer opt, StaticContext env, ItemType contextItemType)
Expressionpromote(PromotionOffer offer)
Offer promotion for this subexpression.
Expressionsimplify(StaticContext env)
Simplify an expression.
ExpressiontypeCheck(StaticContext env, ItemType contextItemType)

Field Detail

isAtomic

boolean isAtomic

isSingleton

boolean isSingleton

select

Expression select

separator

Expression separator

Constructor Detail

SimpleContentConstructor

public SimpleContentConstructor(Expression select, Expression separator)

Method Detail

computeCardinality

protected int computeCardinality()
Compute the cardinality of the result of the expression.

Returns: the cardinality, @link {StaticProperty.EXACTLY_ONE}

display

public void display(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure. The expression is written to the System.err output stream

Parameters: level indentation level for this expression pool NamePool used to expand any names appearing in the expression out Output destination

evaluateItem

public Item evaluateItem(XPathContext context)
Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.

Parameters: context The context in which the expression is to be evaluated

Returns: the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence

Throws: net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the 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 prefered.

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the expression, if possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.

This method should always return a result, though it may be the best approximation that is available at the time.

Parameters: th

Returns: a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

iterateSubExpressions

public Iterator iterateSubExpressions()
Get the immediate sub-expressions of this expression. Default implementation returns a zero-length array, appropriate for an expression that has no sub-expressions.

Returns: an iterator containing the sub-expressions of this expression

optimize

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

promote

public Expression promote(PromotionOffer offer)
Offer promotion for this subexpression. 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

Returns: if the offer is not accepted, return this expression unchanged. Otherwise return the result of rewriting the expression to promote this subexpression

Throws: net.sf.saxon.trans.XPathException if any error is detected

simplify

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

Returns: the simplified expression

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

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)