Message output
XSLT defines the xsl:message instruction to produce output, but leaves nearly all details of its behaviour implementation-defined. Although the content of a message is often a simple text string, the specification defines it as an XML document fragment. By default Saxon serializes this document and writes it to the standard error stream.
A Java application can customize the handling of xsl:message
output by calling the setMessageHandler() method on the XsltTransformer
or Xslt30Transformer. The argument to the message is of type Consumer<Message>
and it will typically be supplied as a lambda expression, for example:
A C# application can customize the handling of xsl:message
output by setting the MessageListener property on the XsltTransformer
or Xslt30Transformer. The argument to the message is of type Action<Message>
and it will typically be supplied as a lambda expression, for example:
The Message object passed to the supplied message handler contains the content of
the message as an XdmNode, the location of the xsl:message instruction,
the error code to be used, and a boolean value indicating whether terminate="yes"
was specified.
A message handler might reformat the message (for example, by adding a timestamp) or it might redirect it to a destination such as a system logging framework, or to a status line in a graphical user interface.