net.sf.saxon.instruct
Class SimpleNodeConstructor

java.lang.Object
  |
  +--net.sf.saxon.expr.ComputedExpression
        |
        +--net.sf.saxon.instruct.Instruction
              |
              +--net.sf.saxon.instruct.InstructionWithChildren
                    |
                    +--net.sf.saxon.instruct.SimpleNodeConstructor
All Implemented Interfaces:
Container, Expression, InstructionInfoProvider, java.io.Serializable, javax.xml.transform.SourceLocator
Direct Known Subclasses:
Attribute, Comment, FixedAttribute, Namespace, ProcessingInstruction, Text, ValueOf

public abstract class SimpleNodeConstructor
extends InstructionWithChildren

Common superclass for XSLT instructions whose content template produces a text value: xsl:attribute, xsl:comment, xsl:processing-instruction, xsl:namespace, and xsl:text

See Also:
Serialized Form

Field Summary
protected  Expression select
           
protected  Expression separator
           
 
Fields inherited from class net.sf.saxon.instruct.InstructionWithChildren
children
 
Fields inherited from class net.sf.saxon.expr.ComputedExpression
locationId, staticProperties
 
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Constructor Summary
SimpleNodeConstructor()
           
 
Method Summary
 Expression analyze(StaticContext env, ItemType contextItemType)
          The analyze() method is called in XQuery, where node constructors are implemented as Expressions.
protected  java.lang.String checkContent(java.lang.String data, XPathContext context)
          Check the content of the node, and adjust it if necessary.
 void display(int level, NamePool pool, java.io.PrintStream out)
          Display this instruction as an expression, for diagnostics
 Item evaluateItem(XPathContext context)
          Evaluate as an expression.
protected  int evaluateNameCode(XPathContext context)
           
 java.lang.CharSequence expandChildren(XPathContext context)
          Expand the stylesheet elements subordinate to this one, returning the result as a string.
 SequenceIterator iterate(XPathContext context)
          Return an Iterator to iterate over the values of a sequence.
 java.util.Iterator iterateSubExpressions()
          Get the immediate sub-expressions of this expression.
protected  void promoteInst(PromotionOffer offer)
          Offer promotion for subexpressions.
 void setSelect(Expression select)
           
 void setSeparator(Expression separator)
           
 Expression simplify(StaticContext env)
          Simplify an expression.
abstract  void typeCheck(StaticContext env, ItemType contextItemType)
           
 
Methods inherited from class net.sf.saxon.instruct.InstructionWithChildren
displayChildren, getChildren, processChildren, processChildrenLeavingTail, setChildren
 
Methods inherited from class net.sf.saxon.instruct.Instruction
appendItem, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, dynamicError, effectiveBooleanValue, evaluateAsString, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getItemType, getSourceLocator, process, processLeavingTail, promote
 
Methods inherited from class net.sf.saxon.expr.ComputedExpression
adoptChildExpression, computeDependencies, computeStaticProperties, dynamicError, dynamicError, getCardinality, getColumnNumber, getConstructType, getDependencies, getExecutable, getIntrinsicDependencies, getLineNumber, getLocationId, getParentExpression, getPublicId, getSpecialProperties, getSystemId, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, typeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.transform.SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
 

Field Detail

select

protected Expression select

separator

protected Expression separator
Constructor Detail

SimpleNodeConstructor

public SimpleNodeConstructor()
Method Detail

setSelect

public void setSelect(Expression select)
               throws StaticError
StaticError

setSeparator

public final void setSeparator(Expression separator)

simplify

public Expression simplify(StaticContext env)
                    throws XPathException
Description copied from class: InstructionWithChildren
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).

Specified by:
simplify in interface Expression
Overrides:
simplify in class InstructionWithChildren
Returns:
the simplified expression
Throws:
XPathException - if an error is discovered during expression rewriting

typeCheck

public abstract void typeCheck(StaticContext env,
                               ItemType contextItemType)
                        throws XPathException
XPathException

analyze

public Expression analyze(StaticContext env,
                          ItemType contextItemType)
                   throws XPathException
The analyze() 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.

Specified by:
analyze in interface Expression
Overrides:
analyze in class InstructionWithChildren
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

iterateSubExpressions

public java.util.Iterator iterateSubExpressions()
Description copied from class: InstructionWithChildren
Get the immediate sub-expressions of this expression.

Specified by:
iterateSubExpressions in interface Expression
Overrides:
iterateSubExpressions in class InstructionWithChildren
Returns:
an iterator containing the sub-expressions of this expression

expandChildren

public java.lang.CharSequence expandChildren(XPathContext context)
                                      throws XPathException
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
XPathException

evaluateItem

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

Specified by:
evaluateItem in interface Expression
Overrides:
evaluateItem in class Instruction
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:
XPathException - if any dynamic error occurs evaluating the expression

checkContent

protected java.lang.String checkContent(java.lang.String data,
                                        XPathContext context)
                                 throws DynamicError
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

evaluateNameCode

protected int evaluateNameCode(XPathContext context)
                        throws XPathException,
                               XPathException
XPathException

iterate

public SequenceIterator iterate(XPathContext context)
                         throws XPathException
Description copied from class: Instruction
Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.

Specified by:
iterate in interface Expression
Overrides:
iterate in class Instruction
Parameters:
context - supplies the context for evaluation
Returns:
a SequenceIterator that can be used to iterate over the result of the expression
Throws:
XPathException - if any dynamic error occurs evaluating the expression

display

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

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

promoteInst

protected void promoteInst(PromotionOffer offer)
                    throws XPathException
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.

Overrides:
promoteInst in class InstructionWithChildren
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