net.sf.saxon.instruct

Class ResultDocument

public class ResultDocument extends Instruction implements DivisibleInstruction

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.

Constructor Summary
ResultDocument(Properties globalProperties, Properties localProperties, Expression href, Expression formatExpression, String baseURI, int validationAction, SchemaType schemaType, IntHashMap<Expression> serializationAttributes, NamespaceResolver nsResolver)
Create a result-document instruction
Method Summary
Expressioncopy()
Copy an expression.
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
ExpressiongetContentExpression()
Get the expression that constructs the content
intgetInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes (the string "xsl:result-document")
intgetIntrinsicDependencies()
ItemTypegetItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction
Iterator<Expression>iterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
TailCallprocessLeavingTail(XPathContext context)
voidprocessLeft(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the first half of the instruction (for example, to start a new document or element)
voidprocessRight(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the right half of the instruction (for example, to end a new document or element)
static voidprocessXslOutputElement(NodeInfo element, Properties props, XPathContext c)
Construct a set of output properties from an xsl:output element supplied at run-time
protected voidpromoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.
booleanreplaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression
voidsetContentExpression(Expression content)
Set the expression that constructs the content
voidsetDynamicOutputElement(Expression exp)
Set an expression that evaluates to a run-time xsl:output element, used in the saxon:result-document() extension function designed for use in XQuery
static voidsetSerializationProperty(Properties details, String uri, String lname, String value, NamespaceResolver nsResolver, boolean prevalidated, Configuration config)
Validate a serialization property and add its value to a Properties collection
voidsetUseStaticBaseUri(boolean staticBase)
Set whether the the instruction should resolve the href relative URI against the static base URI (rather than the dynamic base output URI)
Expressionsimplify(ExpressionVisitor visitor)
Simplify an expression.
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Constructor Detail

ResultDocument

public ResultDocument(Properties globalProperties, Properties localProperties, Expression href, Expression formatExpression, String baseURI, int validationAction, SchemaType schemaType, IntHashMap<Expression> serializationAttributes, NamespaceResolver nsResolver)
Create a result-document instruction

Parameters: globalProperties properties defined on static xsl:output localProperties non-AVT properties defined on result-document element href href attribute of instruction formatExpression format attribute of instruction baseURI base URI of the instruction validationAction for example STRICT schemaType schema type against which output is to be validated serializationAttributes computed local properties nsResolver namespace resolver

Method Detail

copy

public Expression copy()
Copy an expression. This makes a deep copy.

Returns: the copy of the original expression

explain

public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.

getContentExpression

public Expression getContentExpression()
Get the expression that constructs the content

Returns: the content expression

getInstructionNameCode

public int getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes (the string "xsl:result-document")

getIntrinsicDependencies

public int getIntrinsicDependencies()

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the item type of the items returned by evaluating this instruction

Parameters: th the type hierarchy cache

Returns: the static item type of the instruction. This is empty: the result-document instruction returns nothing.

iterateSubExpressions

public Iterator<Expression> iterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction)

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)

processLeavingTail

public TailCall processLeavingTail(XPathContext context)

processLeft

public void processLeft(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the first half of the instruction (for example, to start a new document or element)

Parameters: contextStack state a stack on which the instruction can save state information during the call on processLeft()

processRight

public void processRight(Stack<XPathContext> contextStack, Stack state)
In streaming mode, process the right half of the instruction (for example, to end a new document or element)

Parameters: contextStack state a stack on which the instruction can save state information during the call on processLeft()

processXslOutputElement

public static void processXslOutputElement(NodeInfo element, Properties props, XPathContext c)
Construct a set of output properties from an xsl:output element supplied at run-time

Parameters: element an xsl:output element props Properties object to which will be added the values of those serialization properties that were specified c the XPath dynamic context

promoteInst

protected void promoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites.

Parameters: offer The type of rewrite being offered

Throws: XPathException

replaceSubExpression

public boolean replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression

Parameters: original the original subexpression replacement the replacement subexpression

Returns: true if the original subexpression is found

setContentExpression

public void setContentExpression(Expression content)
Set the expression that constructs the content

Parameters: content the expression defining the content of the result document

setDynamicOutputElement

public void setDynamicOutputElement(Expression exp)
Set an expression that evaluates to a run-time xsl:output element, used in the saxon:result-document() extension function designed for use in XQuery

Parameters: exp the expression whose result should be an xsl:output element

setSerializationProperty

public static void setSerializationProperty(Properties details, String uri, String lname, String value, NamespaceResolver nsResolver, boolean prevalidated, Configuration config)
Validate a serialization property and add its value to a Properties collection

Parameters: details the properties to be updated uri the uri of the property name lname the local part of the property name value the value of the serialization property. In the case of QName-valued values, this will use lexical QNames if prevalidated is false, Clark-format names otherwise nsResolver resolver for lexical QNames; not needed if prevalidated prevalidated true if values are already known to be valid and lexical QNames have been expanded into Clark notation config the Saxon configuration

setUseStaticBaseUri

public void setUseStaticBaseUri(boolean staticBase)
Set whether the 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

simplify

public Expression simplify(ExpressionVisitor visitor)
Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation does nothing.

Parameters: visitor an expression visitor

Returns: the simplified expression

Throws: net.sf.saxon.trans.XPathException if an error is discovered during expression rewriting

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)