Home » XSLT Element

XSLT <xsl:message> Element

The XSLT <xsl:message> element is used to display the error message and help to debug the XSLT processing. It is similar to JavaScript alerts. This element buffers a message to XSLT processor which terminates the processing and sends a message to the caller application to show an error message.


Parameter explanation

Terminate: It specifies if the transformation should terminate upon executing this instruction or not. When the terminate attribute is set to “yes”, the content of the element is displayed as the part of the system-level error message, and the transformation terminates. When it is set to “no”, the transformation proceeds, ignoring the error message. By default value is ?no?.


XSLT <xsl:message> Element Example

For “yes” Condition

Let’s take an example to create a <student> element with its attribute “id” and its child <firstname>, <lastname>, <nickname>, and <salary> by iterating over each employee. It checks key as firstname to be present and then prints the employee’s details, otherwise displays an error message.

Employee.xml

Employee.xsl

Output:

XSLT Xsl message element 1

For “no” Condition

Employee.xsl

Output:

XSLT Xsl message element 1

Next Topic#

You may also like