Class ResultDocument
- All Implemented Interfaces:
ContextOriginator
,ExportAgent
,InstructionWithComplexContent
,ValidatingInstruction
,Locatable
,IdentityComparable
,Traceable
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
ConstructorsConstructorDescriptionResultDocument
(Properties globalProperties, Properties localProperties, Expression href, Expression formatExpression, int validationAction, SchemaType schemaType, Map<StructuredQName, Expression> serializationAttributes, CharacterMapIndex characterMapIndex) Create a result-document instruction -
Method Summary
Modifier and TypeMethodDescriptionaddToPathMap
(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.static void
checkAcceptableUri
(XPathContext context, String uri) copy
(RebindingMap rebindings) Copy an expression.void
Diagnostic print of expression structure.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 declarationGet the subexpression that is used to evaluated the content, that is, the contained sequence constructorMake an elaborator for this expressiongetHref()
int
Get the name of this instruction for diagnostic and tracing purposes (the string "xsl:result-document")int
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.Get the item type of the items returned by evaluating this instructionGet the schema type chosen for validation; null if not definedGet the value of a serialization property if it is statically knownGet the (partial) name of a class that supports streaming of this kind of expressionint
Get the validation mode for this instructionGet the validation optionsboolean
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
static Receiver
makeReceiver
(String hrefValue, String baseURI, XPathContext context, ResultDocumentResolver resolver, SerializationProperties params, boolean resolveAgainstStaticBase) operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent 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.processLeft
(XPathContext context) static void
processXslOutputElement
(NodeInfo element, 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
(Properties details, NamespaceUri uri, String lname, 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, Result result) 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 Details
-
ResultDocument
public ResultDocument(Properties globalProperties, Properties localProperties, Expression href, Expression formatExpression, int validationAction, SchemaType schemaType, 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 Details
-
setContentExpression
Set the expression that constructs the content- Parameters:
content
- the expression defining the content of the result document
-
setSchemaType
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
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
Get the validation options- Returns:
- the validation options for the content of the constructed node. May be null if no validation was requested.
-
setValidationAction
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
-
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
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
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
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
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
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
- Throws:
XPathException
-
processInstruction
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
- Throws:
XPathException
-
getCharacterMapIndex
-
makeReceiver
public static Receiver makeReceiver(String hrefValue, String baseURI, XPathContext context, ResultDocumentResolver resolver, SerializationProperties params, boolean resolveAgainstStaticBase) throws XPathException - Throws:
XPathException
-
traceDestination
-
checkAcceptableUri
- Throws:
XPathException
-
gatherOutputProperties
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
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(Properties details, NamespaceUri uri, String lname, 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
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, 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
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
-
setHref
-
setFormatExpression
-
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
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-