net.sf.saxon.instruct
Class ElementCreator

java.lang.Object
  extended by net.sf.saxon.expr.Expression
      extended by net.sf.saxon.instruct.Instruction
          extended by net.sf.saxon.instruct.ParentNodeConstructor
              extended by net.sf.saxon.instruct.ElementCreator
All Implemented Interfaces:
Serializable, SourceLocator, Container, EvaluableItem, SequenceIterable, TailCallReturner, InstructionInfoProvider
Direct Known Subclasses:
ComputedElement, Copy, FixedElement

public abstract class ElementCreator
extends ParentNodeConstructor

An instruction that creates an element node. There are two subtypes, FixedElement for use where the name is known statically, and Element where it is computed dynamically. To allow use in both XSLT and XQuery, the class acts both as an Instruction and as an Expression.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Constructor Summary
ElementCreator()
           
 
Method Summary
 int computeSpecialProperties()
          Get the static properties of this expression (other than its type).
 Item evaluateItem(XPathContext context)
          Evaluate the constructor, returning the constructed element node.
 int[] getActiveNamespaces()
          Callback to get a list of the intrinsic namespaces that need to be generated for the element.
 int getImplementationMethod()
          An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
 ItemType getItemType(TypeHierarchy th)
          Get the item type of the value returned by this instruction
abstract  int getNameCode(XPathContext context)
           
abstract  String getNewBaseURI(XPathContext context)
          Get the base URI for the element being constructed
 boolean isInheritNamespaces()
          Determine whether the inherit namespaces flag is set
 boolean isValidating()
          Determine whether this elementCreator performs validation
 TailCall processLeavingTail(XPathContext context)
          Evaluate the instruction to produce a new element node.
 void setValidationMode(int mode)
          Set the validation mode for the new element
 void suppressValidation(int validationMode)
          Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation.
 
Methods inherited from class net.sf.saxon.instruct.ParentNodeConstructor
computeCardinality, createsNewNodes, getBaseURI, getCardinality, getContentExpression, getSchemaType, getValidationMode, isLazyConstruction, isNamespaceSensitive, iterateSubExpressions, optimize, replaceSubExpression, setBaseURI, setContentExpression, setLazyConstruction, setSchemaType, simplify, typeCheck
 
Methods inherited from class net.sf.saxon.instruct.Instruction
appendItem, evaluateAsString, getInstructionInfo, getInstructionNameCode, getSourceLocator, isXSLT, iterate, process, promote
 
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, display, doPromotion, effectiveBooleanValue, getColumnNumber, getContainingProcedure, getDependencies, getExecutable, getHostLanguage, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, setParentExpression
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.transform.SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
 

Constructor Detail

ElementCreator

public ElementCreator()
Method Detail

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type of the value returned by this instruction

Overrides:
getItemType in class Instruction
Parameters:
th -
Returns:
the item type

isValidating

public boolean isValidating()
Determine whether this elementCreator performs validation


isInheritNamespaces

public boolean isInheritNamespaces()
Determine whether the inherit namespaces flag is set


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.

Overrides:
computeSpecialProperties in class Instruction
Returns:
a set of flags indicating static properties of this expression

setValidationMode

public void setValidationMode(int mode)
Set the validation mode for the new element

Overrides:
setValidationMode in class ParentNodeConstructor

suppressValidation

public void suppressValidation(int validationMode)
Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation. The default implementation does nothing.

Overrides:
suppressValidation in class Expression

getNameCode

public abstract int getNameCode(XPathContext context)
                         throws XPathException
Throws:
XPathException

getNewBaseURI

public abstract String getNewBaseURI(XPathContext context)
Get the base URI for the element being constructed

Parameters:
context -

getActiveNamespaces

public int[] getActiveNamespaces()
                          throws XPathException
Callback to get a list of the intrinsic namespaces that need to be generated for the element. The result is an array of namespace codes, the codes either occupy the whole array or are terminated by a -1 entry. A result of null is equivalent to a zero-length array.

Throws:
XPathException

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.

Overrides:
getImplementationMethod in class Instruction

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
                            throws XPathException
Evaluate the instruction to produce a new element node. This method is typically used when there is a parent element or document in a result tree, to which the new element is added.

Specified by:
processLeavingTail in interface TailCallReturner
Specified by:
processLeavingTail in class Instruction
Parameters:
context -
Returns:
null (this instruction never returns a tail call)
Throws:
XPathException

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Evaluate the constructor, returning the constructed element node. If lazy construction mode is in effect, then an UnconstructedParent object is returned instead.

Specified by:
evaluateItem in interface EvaluableItem
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


Copyright (C) Michael H. Kay. All rights reserved.