Class ElementCreator
- All Implemented Interfaces:
Serializable
,SourceLocator
,LocationProvider
,SaxonLocator
,EvaluableItem
,SequenceIterable
,TailCallReturner
,InstructionInfo
,Locator
- Direct Known Subclasses:
ComputedElement
,Copy
,FixedElement
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
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.protected boolean
Flag set to true if validation=preserve and no schema type supplied for validationFields inherited from class net.sf.saxon.instruct.ParentNodeConstructor
content
Fields inherited from class net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, locationId, PROCESS_METHOD, staticProperties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Check statically whether the content of the element creates attributes or namespaces after creating any child nodesint
Get 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.int
An 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 int
getNameCode
(XPathContext context) Determine (at run-time) the name code of the element being constructedabstract String
getNewBaseURI
(XPathContext context) Get the base URI for the element being constructedboolean
Determine whether the inherit namespaces flag is setboolean
Determine whether this elementCreator performs validation or strips type annotationsiterateEvents
(XPathContext context) Deliver the result of the expression as a sequence of events.protected abstract void
outputNamespaceNodes
(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.void
setValidationMode
(int mode) Set the validation mode for the new elementvoid
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
addToPathMap, computeCardinality, createsNewNodes, getBaseURI, getCardinality, getContentExpression, getSchemaType, getValidationMode, isLazyConstruction, isNamespaceSensitive, iterateSubExpressions, optimize, promoteInst, replaceSubExpression, setBaseURI, setContentExpression, setLazyConstruction, setSchemaType, simplify, typeCheck
Methods inherited from class net.sf.saxon.instruct.Instruction
assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, getConstructType, getInstructionNameCode, getSourceLocator, isXSLT, iterate, process, promote
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluatePendingUpdates, explain, explain, findParentOf, getColumnNumber, getColumnNumber, getContainer, getDependencies, getExecutable, getHostLanguage, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, isUpdatingExpression, markTailFunctionCalls, resetLocalStaticProperties, setContainer, 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 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. -
preservingTypes
protected boolean preservingTypesFlag set to true if validation=preserve and no schema type supplied for validation
-
-
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:
getItemType
in classInstruction
- Parameters:
th
- the type hierarchy cache- Returns:
- the item type
-
isPreservingTypes
public boolean isPreservingTypes()Determine whether this elementCreator performs validation or strips type annotations- Returns:
- false if the instruction performs validation of the constructed output or if it strips type annotations, otherwise true
-
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 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- Overrides:
setValidationMode
in classParentNodeConstructor
- Parameters:
mode
- the validation mode, for exampleValidation.STRICT
-
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 classExpression
- Parameters:
validationMode
- 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:
checkContentSequence
in classParentNodeConstructor
- Parameters:
env
- the static context- Throws:
XPathException
-
getNameCode
Determine (at run-time) the name code of the element being constructed- Parameters:
context
- the XPath dynamic evaluation context- 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 context- Returns:
- the base URI of the constructed element
-
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.- Returns:
- 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 classInstruction
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.PROCESS_METHOD
-
iterateEvents
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 classExpression
- 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
-
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:
processLeavingTail
in interfaceTailCallReturner
- Specified by:
processLeavingTail
in classInstruction
- Parameters:
context
- XPath dynamic evaluation 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:
evaluateItem
in interfaceEvaluableItem
- Overrides:
evaluateItem
in 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
-