Class ElementCreator
java.lang.Object
net.sf.saxon.expr.ComputedExpression
net.sf.saxon.instruct.Instruction
net.sf.saxon.instruct.ParentNodeConstructor
net.sf.saxon.instruct.ElementCreator
- All Implemented Interfaces:
Serializable, SourceLocator, Container, Expression, TailCallReturner, InstructionInfoProvider
- 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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanThe 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.protected booleanThe validating flag is set if the type attribute is set or if validation is set to anything other than preserve.Fields inherited from class ParentNodeConstructor
content, validationFields inherited from class ComputedExpression
locationId, staticPropertiesFields inherited from interface Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_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.int[]Callback to get a list of the intrinsic namespaces that need to be generated for the element.intAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().Get the item type of the value returned by this instructionabstract intgetNameCode(XPathContext context) abstract StringgetNewBaseURI(XPathContext context) Get the base URI for the element being constructedintGet the validation mode for the constructed elementbooleanDetermine whether the inherit namespaces flag is setbooleanDetermine whether this elementCreator performs validationprotected abstract voidoutputNamespaceNodes(XPathContext context, Receiver receiver) Callback to output namespace nodes for the new element.processLeavingTail(XPathContext context) Evaluate the instruction to produce a new element node.voidsetValidationMode(int mode) Set the validation mode for the new elementvoidsuppressValidation(int validationMode) Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation.Methods inherited from class ParentNodeConstructor
createsNewNodes, getBaseURI, getCardinality, getContentExpression, getSchemaType, getValidationAction, isLazyConstruction, isNamespaceSensitive, iterateSubExpressions, optimize, promoteInst, replaceSubExpression, setBaseURI, setContentExpression, setLazyConstruction, setSchemaType, simplify, typeCheck, verifyLazyConstructionMethods inherited from class Instruction
appendItem, assembleParams, assembleTunnelParams, computeCardinality, dynamicError, evaluateAsString, getInstructionInfo, getInstructionNameCode, getSourceLocator, isXSLT, iterate, process, promoteMethods inherited from class ComputedExpression
adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, getColumnNumber, getConstructType, getDependencies, getExecutable, getHostLanguage, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, typeErrorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Expression
displayMethods inherited from interface SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
-
Field Details
-
inheritNamespaces
protected boolean inheritNamespacesThe 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. -
validating
protected boolean validatingThe validating flag is set if the type attribute is set or if validation is set to anything other than preserve. This is used simply to fast-path the case where no validation is required.
-
-
Constructor Details
-
ElementCreator
public ElementCreator()
-
-
Method Details
-
getItemType
Get the item type of the value returned by this instruction- Specified by:
getItemTypein interfaceExpression- Overrides:
getItemTypein classInstruction- 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:
computeSpecialPropertiesin classInstruction- 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 -
getValidationMode
public int getValidationMode()Get the validation mode for the constructed element -
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:
suppressValidationin classComputedExpression
-
checkContentForAttributes
Check statically whether the content of the element creates attributes or namespaces after creating any child nodes- Specified by:
checkContentForAttributesin classParentNodeConstructor- Parameters:
env- the static context- Throws:
XPathException
-
getNameCode
- Throws:
XPathException
-
getNewBaseURI
Get the base URI for the element being constructed- Parameters:
context-
-
outputNamespaceNodes
protected abstract void outputNamespaceNodes(XPathContext context, Receiver receiver) throws XPathException Callback to output namespace nodes for the new element.- Parameters:
context- The execution contextreceiver- the Receiver where the namespace nodes are to be written- Throws:
XPathException
-
getActiveNamespaces
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.- Specified by:
getImplementationMethodin interfaceExpression- Overrides:
getImplementationMethodin classInstruction
-
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-- Returns:
- null (this instruction never returns a tail call)
- Throws:
XPathException
-
evaluateItem
Evaluate the constructor, returning the constructed element node. If lazy construction mode is in effect, then an UnconstructedParent object is returned instead.- Specified by:
evaluateItemin interfaceExpression- 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
-