Saxon.Api

 

 

Saxon.Api

Delegate ResultDocumentHandler


public delegate IDestination ResultDocumentHandler(string href, Uri baseUri)

A ResultDocumentHandler can be nominated to handle output produced by the xsl:result-document instruction in an XSLT stylesheet. The function is called by the XSLT processor when an xsl:result-document with an href attribute is evaluated.

This callback affects any xsl:result-document instruction executed by the stylesheet, provided that it has an href attribute.

If no ResultDocumentHandler is nominated (in the ResultDocumentHandler property of the XsltTransformer or Xslt30Transformer), the output of xsl:result-document is serialized, and is written to the file or other resource identified by the URI in the href attribute, resolved (if it is relative) against the URI supplied in the BaseOutputUri property of the XsltTransformer.

If a ResultDocumentHandler is nominated, however, it will be called whenever an xsl:result-document instruction with an href attribute is evaluated, and the generated result tree will be passed to the IDestination that it returns.

The XSLT processor will ensure that the stylesheet cannot create two distinct result documents which are sent to the same URI. It is the responsibility of the ResultDocumentHandler to ensure that two distinct result documents are not sent to the same IDestination. Failure to observe this rule can result in output streams being incorrectly closed.

Note that more than one result document can be open at the same time, and that the order of opening, writing, and closing result documents chosen by the processor does not necessarily bear any direct resemblance to the way that the XSLT source code is written. SaxonCS processes xsl:result-document instructions asynchronously, in multiple threads, unless this is suppressed using the configuration property Feature.ALLOW_MULTITHREADING.

Note also that in the event of a dynamic error occurring in the transformation, it is unpredictable which result documents have been successfully written before the failure occurs.

Parameters:

href - An absolute or relative URI. This will be the effective value of the href attribute of the xsl:result-document in the stylesheet.
baseUri - The base URI that should be used for resolving the value of href if it is relative. This will always be the value of the BaseOutputUri property of the XsltTransformer.

Returns:

An IDestination object representing the destination to which the result document is sent.