Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon.expr.instruct
Class ElementCreator

    java.lang.Object
      net.sf.saxon.expr.Expression
          net.sf.saxon.expr.instruct.Instruction
              net.sf.saxon.expr.instruct.ParentNodeConstructor
                  net.sf.saxon.expr.instruct.ElementCreator

All Implemented Interfaces:
  Serializable, SourceLocator, LocationProvider, SaxonLocator, DivisibleInstruction, TailCallReturner, ValidatingInstruction, InstructionInfo, Locator

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
`protected boolean` | `inheritNamespaces` The inheritNamespaces flag indicates that the namespace nodes on the element created by this instruction are to be inherited (copied) on the children of this element.

Fields inherited from class net.sf.saxon.expr.instruct.ParentNodeConstructor
`content, preservingTypes`

Fields inherited from class net.sf.saxon.expr.Expression
`EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD`

Constructor Summary
`ElementCreator()` Construct an ElementCreator.

Method Summary
`protected void` | `checkContentSequence(StaticContext env)` Check statically whether the content of the element creates attributes or namespaces after creating any child nodes
`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.
`NamespaceBinding[]` | `getActiveNamespaces()` Callback to get a list of the intrinsic namespaces that need to be generated for the element.
`abstract NodeName` | `getElementName(XPathContext context, NodeInfo copiedNode)` Determine (at run-time) the name code of the element being constructed
`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
`protected abstract String` | `getNewBaseURI(XPathContext context, NodeInfo copiedNode)` Get the base URI for the element being constructed
`boolean` | `isInheritNamespaces()` Determine whether the inherit namespaces flag is set
`EventIterator` | `iterateEvents(XPathContext context)` Deliver the result of the expression as a sequence of events.
`protected EventIterator` | `iterateEvents(XPathContext context, NodeInfo copiedNode)`
`protected abstract void` | `outputNamespaceNodes(XPathContext context, Receiver receiver, NodeName nameCode, NodeInfo copiedNode)` Callback to output namespace nodes for the new element.
`TailCall` | `processLeavingTail(XPathContext context)` Evaluate the instruction to produce a new element node.
`protected TailCall` | `processLeavingTail(XPathContext context, NodeInfo copiedNode)` Evaluate the instruction to produce a new element node.
`void` | `processLeft(Stack<XPathContext> contextStack, Stack<Object> state)` In streaming mode, process the first half of the instruction (to start a new document or element)
`protected void` | `processLeft(Stack<XPathContext> contextStack, Stack<Object> state, NodeInfo copiedNode)` In streaming mode, process the first half of the instruction (to start a new document or element)
`void` | `processRight(Stack<XPathContext> contextStack, Stack<Object> state)` In streaming mode, proecss the right half of the instruction (to end a new document or element)
`void` | `suppressValidation(int parentValidationMode)` Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation.

Methods inherited from class net.sf.saxon.expr.instruct.ParentNodeConstructor
`addToPathMap, computeCardinality, createsNewNodes, getBaseURI, getCardinality, getContentExpression, getSchemaType, getValidationAction, isLazyConstruction, isNamespaceSensitive, isPreservingTypes, iterateSubExpressions, optimize, promoteInst, replaceSubExpression, setBaseURI, setContentExpression, setLazyConstruction, setNoNeedToStrip, setSchemaType, setValidationAction, simplify, typeCheck`

Methods inherited from class net.sf.saxon.expr.instruct.Instruction
`assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, getConstructType, getExpressionName, getInstructionName, getInstructionNameCode, getIteratorFromProcessMethod, getSourceLocator, isXSLT, iterate, process, promote`

Methods inherited from class net.sf.saxon.expr.Expression
`adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, copy, doPromotion, dynamicError, effectiveBooleanValue, evaluatePendingUpdates, explain, explain, getColumnNumber, getColumnNumber, getContainer, getDependencies, getEvaluationMethod, getExecutable, getHostLanguage, getIntegerBounds, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateSameFocusSubExpressions, markTailFunctionCalls, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, toString, typeError`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface javax.xml.transform.SourceLocator
`getColumnNumber, getLineNumber, getPublicId, getSystemId`

Field Detail

### inheritNamespaces

    protected boolean inheritNamespaces

  The inheritNamespaces flag indicates that the namespace nodes on the element created by this instruction are to be inherited (copied) on the children of this element. That is, if this flag is false, the child elements must carry a namespace undeclaration for all the namespaces on the parent, unless they are redeclared in some way.

Constructor Detail

### ElementCreator

    public ElementCreator()

  Construct an ElementCreator. Exists for the benefit of subclasses.

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` - the type hierarchy cache
  Returns:
    the item type

### isInheritNamespaces

    public boolean isInheritNamespaces()

  Determine whether the inherit namespaces flag is set

  Returns:
    true if namespaces constructed on a parent element are to be inherited by its children

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

### suppressValidation

    public void suppressValidation(int parentValidationMode)

  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`
  Parameters:
    `parentValidationMode` - the kind of validation being performed on the parent expression

### checkContentSequence

    protected void checkContentSequence(StaticContext env)
                                 throws XPathException

  Check statically whether the content of the element creates attributes or namespaces after creating any child nodes

  Specified by:
    `checkContentSequence` in class `ParentNodeConstructor`
  Parameters:
    `env` - the static context
  Throws:
    `XPathException`

### getElementName

    public abstract NodeName getElementName(XPathContext context,
                                            NodeInfo copiedNode)
                                     throws XPathException

  Determine (at run-time) the name code of the element being constructed

  Parameters:
    `context` - the XPath dynamic evaluation context
    `copiedNode` - for the benefit of xsl:copy, the node being copied; otherwise null
  Returns:
    the integer name code representing the element name
  Throws:
    `XPathException` - if a failure occurs

### getNewBaseURI

    protected abstract String getNewBaseURI(XPathContext context,
                                            NodeInfo copiedNode)

  Get the base URI for the element being constructed

  Parameters:
    `context` - the XPath dynamic evaluation context
    `copiedNode` - the node being copied (for xsl:copy), otherwise null
  Returns:
    the base URI of the constructed element

### outputNamespaceNodes

    protected abstract void outputNamespaceNodes(XPathContext context,
                                                 Receiver receiver,
                                                 NodeName nameCode,
                                                 NodeInfo copiedNode)
                                          throws XPathException

  Callback to output namespace nodes for the new element. This method is responsible for ensuring that a namespace node is always generated for the namespace of the element name itself.

  Parameters:
    `context` - The execution context
    `receiver` - the Receiver where the namespace nodes are to be written
    `nameCode` - the name code of the element being created
    `copiedNode` - the node being copied (for xsl:copy) or null otherwise
  Throws:
    `XPathException` - if a dynamic error occurs

### getActiveNamespaces

    public NamespaceBinding[] getActiveNamespaces()
                                           throws XPathException

  Callback to get a list of the intrinsic namespaces that need to be generated for the element.

  Returns:
    the set of namespace bindings.
  Throws:
    `XPathException` - if an error occurs

### 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`
  Returns:
    the implementation method, for example `Expression.ITERATE_METHOD` or `Expression.EVALUATE_METHOD` or `Expression.PROCESS_METHOD`

### iterateEvents

    public EventIterator iterateEvents(XPathContext context)
                                throws XPathException

  Description copied from class: `Expression`
  Deliver the result of the expression as a sequence of events.

  The events (of class `PullEvent`) are either complete items, or one of startElement, endElement, startDocument, or endDocument, known as semi-nodes. The stream of events may also include a nested EventIterator. If a start-end pair exists in the sequence, then the events between this pair represent the content of the document or element. The content sequence will have been processed to the extent that any attribute and namespace nodes in the content sequence will have been merged into the startElement event. Namespace fixup will have been performed: that is, unique prefixes will have been allocated to element and attribute nodes, and all namespaces will be declared by means of a namespace node in the startElement event or in an outer startElement forming part of the sequence. However, duplicate namespaces may appear in the sequence.

  The content of an element or document may include adjacent or zero-length text nodes, atomic values, and nodes represented as nodes rather than broken down into events.

  Overrides:
    `iterateEvents` in class `Expression`
  Parameters:
    `context` - The dynamic evaluation context
  Returns:
    the result of the expression as an iterator over a sequence of PullEvent objects
  Throws:
    `XPathException` - if a dynamic error occurs during expression evaluation

### iterateEvents

    protected EventIterator iterateEvents(XPathContext context,
                                          NodeInfo copiedNode)
                                   throws XPathException

  Throws:
    `XPathException`

### 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` - XPath dynamic evaluation context
  Returns:
    null (this instruction never returns a tail call)
  Throws:
    `XPathException`

### processLeavingTail

    protected final TailCall processLeavingTail(XPathContext context,
                                                NodeInfo copiedNode)
                                         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.

  Parameters:
    `context` - XPath dynamic evaluation context
    `copiedNode` - null except in the case of xsl:copy, when it is the node being copied; otherwise null
  Returns:
    null (this instruction never returns a tail call)
  Throws:
    `XPathException` - if a dynamic error occurs

### processLeft

    public void processLeft(Stack<XPathContext> contextStack,
                            Stack<Object> state)
                     throws XPathException

  In streaming mode, process the first half of the instruction (to start a new document or element)

  Parameters:
    `contextStack` - the dynamic evaluation context
    `state` - a stack on which the instruction can save state information for use during the corresponding
  Throws:
    `XPathException` - if a dynamic error occurs

### processLeft

    protected final void processLeft(Stack<XPathContext> contextStack,
                                     Stack<Object> state,
                                     NodeInfo copiedNode)
                              throws XPathException

  In streaming mode, process the first half of the instruction (to start a new document or element)

  Parameters:
    `contextStack` - the dynamic evaluation context
    `state` - a stack on which the instruction can save state information for use during the corresponding
    `copiedNode` - for the benefit of xsl:copy, the node being copied; otherwise null
  Throws:
    `XPathException` - if a dynamic error occurs

### processRight

    public void processRight(Stack<XPathContext> contextStack,
                             Stack<Object> state)
                      throws XPathException

  In streaming mode, proecss the right half of the instruction (to end a new document or element)

  Parameters:
    `contextStack` - the stack of XPath context objects for the current execution state
    `state` - a stack on which the instruction can save state information for use during the corresponding
  Throws:
    `XPathException` - if a dynamic error occurs

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

  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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.