saxon:message-count

Returns a count of the number of messages that have been output using xsl:message.

message-count($errCode as xs:QName?) ➔ xs:integer

Arguments

 

$errCode

xs:QName?

The error code associated with the messages

Result

xs:integer

Namespace

http://saxon.sf.net/

Saxon availability

Requires Saxon-PE or Saxon-EE. Implemented since Saxon 9.8.

Notes on the Saxon implementation

Available since Saxon 9.8.

Details

If the $errCode argument is set to an empty sequence, the function returns the total number of times that the xsl:message instruction has been executed, during the current transformation.

If the $errCode argument is set to a QName, the function returns the total number of times that the xsl:message instruction has been executed, during the current transformation, with that QName as the error code value.

Because this function relies on xsl:message having side-effects, the result is not always guaranteed predictable.

Typical use cases include not outputting further messages after a certain threshold has been reached, or terminating execution after a certain threshold has been reached.

The function can also be used for diagnostic instrumentation, for example counting how many times a particular method has been executed (the "error code", of course, can be any QName and does not need to represent an actual error).

The counters maintained by xsl:message are also available on completion of the transformation through the Java method Controller.getMessageCounters().