Class DocumentInstr
- All Implemented Interfaces:
Serializable
,SourceLocator
,LocationProvider
,SaxonLocator
,DivisibleInstruction
,TailCallReturner
,ValidatingInstruction
,InstructionInfo
,Locator
Conceptually it represents an XSLT instruction xsl:document-node, with no attributes, whose content is a complex content constructor for the children of the document node.
- See Also:
-
Field Summary
Fields inherited from class net.sf.saxon.expr.instruct.ParentNodeConstructor
content, preservingTypes, validation
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
ConstructorsConstructorDescriptionDocumentInstr
(boolean textOnly, String constantText, String baseURI) Create a document constructor instruction -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Check statically that the sequence of child instructions doesn't violate any obvious constraints on the content of the nodeprotected static void
checkContentSequence
(StaticContext env, Expression content, int validation, SchemaType type) int
Get the static properties of this expression (other than its type).copy()
Copy an expression.evaluateItem
(XPathContext context) Evaluate as an item.void
Diagnostic print of expression structure.For a text-only instruction, determine if the text value is fixed and if so return it; otherwise return nullint
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().int
Get the name of this instruction for diagnostic and tracing purposes (the string "document-constructor")Get the item typeIn the case of a text-only instruction (xsl:variable containing a text node or one or more xsl:value-of instructions), return an expression that evaluates to the textual content as an instance of xs:untypedAtomicboolean
Determine whether this is a "text only" document: essentially, an XSLT xsl:variable that contains a single text node or xsl:value-of instruction.iterateEvents
(XPathContext context) Deliver the result of the expression as a sequence of events.processLeavingTail
(XPathContext context) ProcessLeavingTail: called to do the real work of this instruction.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)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)simplify
(ExpressionVisitor visitor) Simplify an expression.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, typeCheck, verifyLazyConstruction
Methods inherited from class net.sf.saxon.expr.instruct.Instruction
assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, getConstructType, getExpressionName, getInstructionName, getIteratorFromProcessMethod, getSourceLocator, isXSLT, iterate, process, promote
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluatePendingUpdates, 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, suppressValidation, 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
-
Constructor Details
-
DocumentInstr
Create a document constructor instruction- Parameters:
textOnly
- true if the content contains text nodes onlyconstantText
- if the content contains text nodes only and the text is known at compile time, supplies the textual contentbaseURI
- the base URI of the instruction
-
-
Method Details
-
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
-
isTextOnly
public boolean isTextOnly()Determine whether this is a "text only" document: essentially, an XSLT xsl:variable that contains a single text node or xsl:value-of instruction.- Returns:
- true if this is a text-only document
-
getConstantText
For a text-only instruction, determine if the text value is fixed and if so return it; otherwise return null- Returns:
- the fixed text value if appropriate; otherwise null
-
simplify
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.- Overrides:
simplify
in classParentNodeConstructor
- Parameters:
visitor
- an expression visitor- Returns:
- the simplified expression
- Throws:
XPathException
- if an error is discovered during expression rewriting
-
checkContentSequence
Check statically that the sequence of child instructions doesn't violate any obvious constraints on the content of the node- Specified by:
checkContentSequence
in classParentNodeConstructor
- Parameters:
env
- the static context- Throws:
XPathException
-
checkContentSequence
protected static void checkContentSequence(StaticContext env, Expression content, int validation, SchemaType type) throws XPathException - Throws:
XPathException
-
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
-
getStringValueExpression
In the case of a text-only instruction (xsl:variable containing a text node or one or more xsl:value-of instructions), return an expression that evaluates to the textual content as an instance of xs:untypedAtomic- Returns:
- an expression that evaluates to the textual content
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Returns:
- the copy of the original expression
-
getItemType
Get the item type- Overrides:
getItemType
in classInstruction
- Parameters:
th
- The TypeHierarchy- Returns:
- the in
-
processLeavingTail
Description copied from class:Instruction
ProcessLeavingTail: called to do the real work of this instruction. This method must be implemented in each subclass. The results of the instruction are written to the current Receiver, which can be obtained via the Controller.- Specified by:
processLeavingTail
in interfaceTailCallReturner
- Specified by:
processLeavingTail
in classInstruction
- Parameters:
context
- The dynamic context of the transformation, giving access to the current node, the current variables, etc.- Returns:
- null if the instruction has completed execution; or a TailCall indicating a function call or template call that is delegated to the caller, to be made after the stack has been unwound so as to save stack space.
- Throws:
XPathException
- if a dynamic error occurs during the evaluation of the instruction
-
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 contextstate
- a stack on which the instruction can save state information for use during the corresponding- 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 dynamic evaluation contextstate
- a stack on which the instruction can save state information for use during the corresponding- Throws:
XPathException
- if a dynamic error occurs
-
evaluateItem
Evaluate as an item.- 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
-
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
-
getInstructionNameCode
public int getInstructionNameCode()Get the name of this instruction for diagnostic and tracing purposes (the string "document-constructor")- Overrides:
getInstructionNameCode
in classInstruction
- Returns:
- a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
-
explain
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
explain
in classExpression
- Parameters:
out
- the expression presenter used to display the structure
-