Package 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:
ExportAgent,InstructionWithComplexContent,TailCallReturner,ValidatingInstruction,Locatable,IdentityComparable
- Direct Known Subclasses:
ComputedElement,Copy,FixedElement
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanThe inheritNamespacesFromParent flag indicates that this element should inherit the namespaces of its parent element in the result tree.protected booleanThe inheritNamespacesToChildren 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
contentOp, preservingTypesFields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck statically whether the content of the element creates attributes or namespaces after creating any child nodesintGet the static properties of this expression (other than its type).evaluateItem(XPathContext context) Evaluate the constructor, returning the constructed element node.protected voidCallback to get a list of the intrinsic namespaces that need to be generated for the element.intDetermine the static cardinality of the expression.abstract NodeNamegetElementName(XPathContext context, NodeInfo copiedNode) Determine (at run-time) the name code of the element being constructedintAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().protected StringGet the item type of the value returned by this instructionabstract StringgetNewBaseURI(XPathContext context, NodeInfo copiedNode) Get the base URI for the element being constructedGet the (partial) name of a class that supports streaming of this kind of expressionbooleanAsk whether this element inherits namespaces from its parent.booleanAsk whether the inherit namespaces flag is setabstract voidoutputNamespaceNodes(XPathContext context, Receiver receiver, NodeName nameCode, NodeInfo copiedNode) Callback to output namespace nodes for the new element.processLeavingTail(XPathContext context) Evaluate the instruction to produce a new element node.final TailCallprocessLeavingTail(XPathContext context, NodeInfo copiedNode) Evaluate the instruction to produce a new element node.voidsetInheritanceFlags(String flags) voidsetInheritNamespacesFromParent(boolean inherit) Say whether this element causes inherits namespaces from its parent.voidsetInheritNamespacesToChildren(boolean inherit) Say whether this element causes its children to inherit namespacesvoidsuppressValidation(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, allowExtractingCommonSubexpressions, alwaysCreatesNewNodes, computeCardinality, getContentExpression, getContentOperand, getSchemaType, getValidationAction, getValidationOptions, isLazyConstruction, isLocal, isPreservingTypes, mayCreateNewNodes, optimize, setBaseURI, setContentExpression, setLazyConstruction, setNoNeedToStrip, setValidationAction, typeCheckMethods inherited from class net.sf.saxon.expr.instruct.Instruction
assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, getConstructType, getExpressionName, getInstructionNameCode, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, operands, process, someOperandCreatesNewNodesMethods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, copy, dynamicError, effectiveBooleanValue, equals, evaluatePendingUpdates, explain, export, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Field Details
-
inheritNamespacesToChildren
protected boolean inheritNamespacesToChildrenThe inheritNamespacesToChildren 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. -
inheritNamespacesFromParent
protected boolean inheritNamespacesFromParentThe inheritNamespacesFromParent flag indicates that this element should inherit the namespaces of its parent element in the result tree. That is, if this flag is false, this element must carry a namespace undeclaration for all the namespaces on its parent, unless they are redeclared in some way.
-
-
Constructor Details
-
ElementCreator
public ElementCreator()Construct an ElementCreator. Exists for the benefit of subclasses.
-
-
Method Details
-
getItemType
Get the item type of the value returned by this instruction- Overrides:
getItemTypein classInstruction- Returns:
- the item type
-
getCardinality
public int getCardinality()Description copied from class:ExpressionDetermine the static cardinality of the expression. This establishes how many items there will be in the result of the expression, at compile time (i.e., without actually evaluating the result.- Overrides:
getCardinalityin classParentNodeConstructor- Returns:
- one of the values Cardinality.ONE_OR_MORE, Cardinality.ZERO_OR_MORE, Cardinality.EXACTLY_ONE, Cardinality.ZERO_OR_ONE, Cardinality.EMPTY. This default implementation returns ZERO_OR_MORE (which effectively gives no information).
-
setInheritNamespacesToChildren
public void setInheritNamespacesToChildren(boolean inherit) Say whether this element causes its children to inherit namespaces- Parameters:
inherit- true if namespaces are to be inherited by the children
-
isInheritNamespacesToChildren
public boolean isInheritNamespacesToChildren()Ask whether the inherit namespaces flag is set- Returns:
- true if namespaces constructed on this parent element are to be inherited by its children
-
setInheritNamespacesFromParent
public void setInheritNamespacesFromParent(boolean inherit) Say whether this element causes inherits namespaces from its parent. True except in XQuery where one direct element constructor forms the immediate content of another (see W3C bug 22334)- Parameters:
inherit- true if namespaces are to be inherited from the parent
-
isInheritNamespacesFromParent
public boolean isInheritNamespacesFromParent()Ask whether this element inherits namespaces from its parent. True except in XQuery where one direct element constructor forms the immediate content of another (see W3C bug 22334)- Returns:
- true if this child element inherits namespaces from its parent element
-
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:
computeSpecialPropertiesin classInstruction- 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:
suppressValidationin classExpression- Parameters:
parentValidationMode- the kind of validation being performed on the parent expression
-
checkContentSequence
Check statically whether the content of the element creates attributes or namespaces after creating any child nodes- Specified by:
checkContentSequencein classParentNodeConstructor- Parameters:
env- the static context- Throws:
XPathException- if the content is found to be incorrect
-
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 contextcopiedNode- 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
Get the base URI for the element being constructed- Parameters:
context- the XPath dynamic evaluation contextcopiedNode- the node being copied (for xsl:copy), otherwise null- Returns:
- the base URI of the constructed element
-
outputNamespaceNodes
public 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 contextreceiver- the Receiver where the namespace nodes are to be writtennameCode- the name code of the element being createdcopiedNode- the node being copied (for xsl:copy) or null otherwise- Throws:
XPathException- if a dynamic error occurs
-
getActiveNamespaces
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:
getImplementationMethodin classInstruction- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
processLeavingTail
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:
processLeavingTailin interfaceTailCallReturner- Specified by:
processLeavingTailin classInstruction- Parameters:
context- XPath dynamic evaluation context- Returns:
- null (this instruction never returns a tail call)
- Throws:
XPathException- if a dynamic error occurs
-
processLeavingTail
public 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 contextcopiedNode- 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
-
evaluateItem
Evaluate the constructor, returning the constructed element node. If lazy construction mode is in effect, then an UnconstructedParent object is returned instead.- Overrides:
evaluateItemin classInstruction- 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
-
exportValidationAndType
-
getInheritanceFlags
-
setInheritanceFlags
-
getStreamerName
Get the (partial) name of a class that supports streaming of this kind of expression- Overrides:
getStreamerNamein classExpression- Returns:
- the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
-