net.sf.saxon.instruct
Class SimpleNodeConstructor

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

public abstract class SimpleNodeConstructor
extends ExprInstruction

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.Instruction
children
 
Constructor Summary
SimpleNodeConstructor()
           
 
Method Summary
 Expression analyze(StaticContext env)
          The analyze() method is called in XQuery, where node constructors are implemented as Expressions.
 void display(int level, NamePool pool)
          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.
 void getXPathExpressions(java.util.List list)
          Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)
 void promoteInst(PromotionOffer offer)
          Offer promotion for subexpressions.
 void setSelect(Expression select)
           
 void setSeparator(Expression separator)
           
abstract  void typeCheck(StaticContext env)
           
 
Methods inherited from class net.sf.saxon.instruct.ExprInstruction
effectiveBooleanValue, evaluateAsString, getDependencies, getSpecialProperties, getSubExpressions, iterate, promote, simplify
 
Methods inherited from class net.sf.saxon.instruct.Instruction
assembleParams, assembleTunnelParams, displayChildren, dynamicError, dynamicError, getCardinality, getChildren, getColumnNumber, getExecutable, getInstructionName, getInstructionNamespace, getItemType, getLineNumber, getPublicId, getSourceLocator, getSystemId, process, processChildren, processChildrenLeavingTail, processLeavingTail, recoverableError, setChildren, setExecutable, setSourceLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.expr.Expression
getCardinality, getItemType
 

Field Detail

select

protected Expression select

separator

protected Expression separator
Constructor Detail

SimpleNodeConstructor

public SimpleNodeConstructor()
Method Detail

setSelect

public final void setSelect(Expression select)

setSeparator

public final void setSeparator(Expression separator)

typeCheck

public abstract void typeCheck(StaticContext env)
                        throws XPathException
XPathException

analyze

public Expression analyze(StaticContext env)
                   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 ExprInstruction
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

getXPathExpressions

public void getXPathExpressions(java.util.List list)
Description copied from class: ExprInstruction
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)

Specified by:
getXPathExpressions in class ExprInstruction
Parameters:
list - A list to be populated with the list of XPath expressions

expandChildren

public java.lang.CharSequence expandChildren(XPathContext context)
                                      throws javax.xml.transform.TransformerException
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
javax.xml.transform.TransformerException

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 ExprInstruction
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

evaluateNameCode

protected int evaluateNameCode(XPathContext context)
                        throws XPathException,
                               javax.xml.transform.TransformerException
XPathException
javax.xml.transform.TransformerException

display

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

Parameters:
level - indentation level for this expression

promoteInst

public 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.

Specified by:
promoteInst in class ExprInstruction
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