Class ResultDocument
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.instruct.Instruction
-
- net.sf.saxon.expr.instruct.ResultDocument
-
- All Implemented Interfaces:
ContextOriginator
,ExportAgent
,InstructionWithComplexContent
,ValidatingInstruction
,Locatable
,IdentityComparable
,Traceable
public class ResultDocument extends Instruction implements ValidatingInstruction, InstructionWithComplexContent, ContextOriginator
The compiled form of an xsl:result-document element in the stylesheet.The xsl:result-document element takes an attribute href="filename". The filename will often contain parameters, e.g. {position()} to ensure that a different file is produced for each element instance.
There is a further attribute "format" which determines the format of the output file, it identifies the name of an xsl:output element containing the output format details. In addition, individual serialization properties may be specified as attributes. These are attribute value templates, so they may need to be computed at run-time.
-
-
Field Summary
-
Fields 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 Constructor Description ResultDocument(java.util.Properties globalProperties, java.util.Properties localProperties, Expression href, Expression formatExpression, int validationAction, SchemaType schemaType, java.util.Map<StructuredQName,Expression> serializationAttributes, CharacterMapIndex characterMapIndex)
Create a result-document instruction
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PathMap.PathMapNodeSet
addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.static void
checkAcceptableUri(XPathContext context, java.lang.String uri)
Expression
copy(RebindingMap rebindings)
Copy an expression.void
export(ExpressionPresenter out)
Diagnostic print of expression structure.java.util.Properties
gatherOutputProperties(XPathContext context)
Create a properties object that combines the serialization properties specified on the xsl:result-document itself with those specified in the referenced xsl:output declarationCharacterMapIndex
getCharacterMapIndex()
Expression
getContentExpression()
Get the subexpression that is used to evaluated the content, that is, the contained sequence constructorElaborator
getElaborator()
Make an elaborator for this expressionExpression
getFormatExpression()
Expression
getHref()
int
getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes (the string "xsl:result-document")int
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.ItemType
getItemType()
Get the item type of the items returned by evaluating this instructionSchemaType
getSchemaType()
Get the schema type chosen for validation; null if not definedjava.lang.String
getStaticSerializationProperty(StructuredQName name)
Get the value of a serialization property if it is statically knownjava.lang.String
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expressionint
getValidationAction()
Get the validation mode for this instructionParseOptions
getValidationOptions()
Get the validation optionsboolean
isAsynchronous()
Ask if the instruction is to be asynchronousboolean
isMultiThreaded(Configuration config)
Ask whether the expression is multithreaded (that is, whether its operands are evaluated in parallel)boolean
isResolveAgainstStaticBase()
static Receiver
makeReceiver(java.lang.String hrefValue, java.lang.String baseURI, XPathContext context, ResultDocumentResolver resolver, SerializationProperties params, boolean resolveAgainstStaticBase)
java.lang.Iterable<Operand>
operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.Expression
optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Perform optimisation of an expression and its subexpressions.void
process(PushEvaluator content, XPathContext context)
void
processInstruction(PushEvaluator content, XPathContext context)
Evaluation method designed for calling from compiled bytecode.ComplexContentOutputter
processLeft(XPathContext context)
static void
processXslOutputElement(NodeInfo element, java.util.Properties props, XPathContext c)
Construct a set of output properties from an xsl:output element supplied at run-timevoid
setAsynchronous(boolean async)
void
setContentExpression(Expression content)
Set the expression that constructs the contentvoid
setFormatExpression(Expression formatExpression)
void
setHref(Expression href)
void
setSchemaType(SchemaType type)
Set the schema type to be used for validationstatic void
setSerializationProperty(java.util.Properties details, NamespaceUri uri, java.lang.String lname, java.lang.String value, NamespaceResolver nsResolver, boolean prevalidated, Configuration config)
Validate a serialization property and add its value to a Properties collectionvoid
setUseStaticBaseUri(boolean staticBase)
Set whether the instruction should resolve the href relative URI against the static base URI (rather than the dynamic base output URI)void
setValidationAction(int mode, SchemaType schemaType)
Set the validation mode for the new documentstatic void
traceDestination(XPathContext context, javax.xml.transform.Result result)
Expression
typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Perform type checking of an expression and its subexpressions.-
Methods inherited from class net.sf.saxon.expr.instruct.Instruction
alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, evaluateAsString, evaluateItem, getExpressionName, getImplementationMethod, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, mayCreateNewNodes, process, someOperandCreatesNewNodes
-
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
ResultDocument
public ResultDocument(java.util.Properties globalProperties, java.util.Properties localProperties, Expression href, Expression formatExpression, int validationAction, SchemaType schemaType, java.util.Map<StructuredQName,Expression> serializationAttributes, CharacterMapIndex characterMapIndex)
Create a result-document instruction- Parameters:
globalProperties
- properties defined on static xsl:outputlocalProperties
- non-AVT properties defined on result-document elementhref
- href attribute of instructionformatExpression
- format attribute of instructionvalidationAction
- for exampleValidation.STRICT
schemaType
- schema type against which output is to be validatedserializationAttributes
- computed local propertiescharacterMapIndex
- index of named character maps
-
-
Method Detail
-
setContentExpression
public void setContentExpression(Expression content)
Set the expression that constructs the content- Parameters:
content
- the expression defining the content of the result document
-
setSchemaType
public void setSchemaType(SchemaType type)
Set the schema type to be used for validation- Parameters:
type
- the type to be used for validation. (For a document constructor, this is the required type of the document element)
-
getSchemaType
public SchemaType getSchemaType()
Get the schema type chosen for validation; null if not defined- Specified by:
getSchemaType
in interfaceValidatingInstruction
- Returns:
- the type to be used for validation. (For a document constructor, this is the required type of the document element)
-
isResolveAgainstStaticBase
public boolean isResolveAgainstStaticBase()
-
getValidationOptions
public ParseOptions getValidationOptions()
Get the validation options- Returns:
- the validation options for the content of the constructed node. May be null if no validation was requested.
-
setValidationAction
public void setValidationAction(int mode, SchemaType schemaType)
Set the validation mode for the new document- Parameters:
mode
- the validation mode, for exampleValidation.STRICT
schemaType
- the required type (for validation by type). Null if not validating by type
-
getValidationAction
public int getValidationAction()
Get the validation mode for this instruction- Specified by:
getValidationAction
in interfaceValidatingInstruction
- Returns:
- the validation mode, for example
Validation.STRICT
orValidation.PRESERVE
-
getFormatExpression
public Expression getFormatExpression()
-
setUseStaticBaseUri
public void setUseStaticBaseUri(boolean staticBase)
Set whether the instruction should resolve the href relative URI against the static base URI (rather than the dynamic base output URI)- Parameters:
staticBase
- set to true by fn:put(), to resolve against the static base URI of the query. Default is false, which causes resolution against the base output URI obtained dynamically from the Controller
-
setAsynchronous
public void setAsynchronous(boolean async)
-
isAsynchronous
public boolean isAsynchronous()
Ask if the instruction is to be asynchronous- Returns:
- true unless saxon:asynchronous="no" was specified (regardless of other options that might suppress asychronous operation)
-
isMultiThreaded
public boolean isMultiThreaded(Configuration config)
Description copied from class:Expression
Ask whether the expression is multithreaded (that is, whether its operands are evaluated in parallel)- Overrides:
isMultiThreaded
in classExpression
- Parameters:
config
- the Saxon configuration- Returns:
- true if execution will be multithreaded
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Description copied from class:Expression
Perform type checking of an expression and its subexpressions. This is the second phase of static optimization.This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.
- Overrides:
typeCheck
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
getIntrinsicDependencies
public int getIntrinsicDependencies()
Description copied from class:Expression
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".- Overrides:
getIntrinsicDependencies
in classExpression
- Returns:
- an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Description copied from class:Expression
Perform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
- Overrides:
optimize
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set toType.ITEM_TYPE
- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- variable bindings that need to be changed- Returns:
- the copy of the original expression
-
getInstructionNameCode
public int getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes (the string "xsl:result-document")- Overrides:
getInstructionNameCode
in classInstruction
- Returns:
- a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
-
getItemType
public ItemType getItemType()
Get the item type of the items returned by evaluating this instruction- Overrides:
getItemType
in classInstruction
- Returns:
- the static item type of the instruction. This is empty: the result-document instruction returns nothing.
-
operands
public java.lang.Iterable<Operand> operands()
Description copied from class:Expression
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Specified by:
operands
in classInstruction
- Returns:
- an iterator containing the sub-expressions of this expression
-
addToPathMap
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.
- Overrides:
addToPathMap
in classExpression
- Parameters:
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be added- Returns:
- the pathMapNodeSet representing the points in the source document that are both reachable by this expression, and that represent possible results of this expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.
-
process
public void process(PushEvaluator content, XPathContext context) throws XPathException
- Throws:
XPathException
-
processInstruction
public void processInstruction(PushEvaluator content, XPathContext context) throws XPathException
Evaluation method designed for calling from compiled bytecode.- Parameters:
content
- The content expression. When called from bytecode, this will be the compiled version of the interpreted content expressioncontext
- dynamic evaluation context- Throws:
XPathException
- if a dynamic error occurs
-
processLeft
public ComplexContentOutputter processLeft(XPathContext context) throws XPathException
- Throws:
XPathException
-
getCharacterMapIndex
public CharacterMapIndex getCharacterMapIndex()
-
makeReceiver
public static Receiver makeReceiver(java.lang.String hrefValue, java.lang.String baseURI, XPathContext context, ResultDocumentResolver resolver, SerializationProperties params, boolean resolveAgainstStaticBase) throws XPathException
- Throws:
XPathException
-
traceDestination
public static void traceDestination(XPathContext context, javax.xml.transform.Result result)
-
checkAcceptableUri
public static void checkAcceptableUri(XPathContext context, java.lang.String uri) throws XPathException
- Throws:
XPathException
-
gatherOutputProperties
public java.util.Properties gatherOutputProperties(XPathContext context) throws XPathException
Create a properties object that combines the serialization properties specified on the xsl:result-document itself with those specified in the referenced xsl:output declaration- Parameters:
context
- The XPath evaluation context- Returns:
- the assembled properties
- Throws:
XPathException
- if invalid properties are found
-
getStaticSerializationProperty
public java.lang.String getStaticSerializationProperty(StructuredQName name)
Get the value of a serialization property if it is statically known- Parameters:
name
- the name of the serialization property- Returns:
- the value of the serialization property if known statically; or null otherwise
-
setSerializationProperty
public static void setSerializationProperty(java.util.Properties details, NamespaceUri uri, java.lang.String lname, java.lang.String value, NamespaceResolver nsResolver, boolean prevalidated, Configuration config) throws XPathException
Validate a serialization property and add its value to a Properties collection- Parameters:
details
- the properties to be updateduri
- the uri of the property namelname
- the local part of the property namevalue
- the value of the serialization property. In the case of QName-valued values, this will use lexical QNames if prevalidated is false and a NamespaceResolver is supplied; otherwise they will use Clark-format namesnsResolver
- resolver for lexical QNames; not needed if prevalidated, or if QNames are supplied in Clark formatprevalidated
- true if values are already known to be valid and lexical QNames have been expanded into Clark notationconfig
- the Saxon configuration- Throws:
XPathException
- if any serialization property has an invalid value
-
export
public void export(ExpressionPresenter out) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classExpression
- Parameters:
out
- the expression presenter used to display the structure- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
processXslOutputElement
public static void processXslOutputElement(NodeInfo element, java.util.Properties props, XPathContext c) throws XPathException
Construct a set of output properties from an xsl:output element supplied at run-time- Parameters:
element
- an xsl:output elementprops
- Properties object to which will be added the values of those serialization properties that were specifiedc
- the XPath dynamic context- Throws:
XPathException
- if a dynamic error occurs
-
getStreamerName
public java.lang.String getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expression- Overrides:
getStreamerName
in 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
-
getHref
public Expression getHref()
-
setHref
public void setHref(Expression href)
-
setFormatExpression
public void setFormatExpression(Expression formatExpression)
-
getContentExpression
public Expression getContentExpression()
Description copied from interface:InstructionWithComplexContent
Get the subexpression that is used to evaluated the content, that is, the contained sequence constructor- Specified by:
getContentExpression
in interfaceInstructionWithComplexContent
- Returns:
- the expression that constructs the content
-
getElaborator
public Elaborator getElaborator()
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-
-