Start of Content Area

Function documentation Error Handling in XSLT  Locate the document in its SAP Library structure


In substantial XSLT programs it makes sense for the system to display an explanatory message when an error occurs. For this purpose there is the XSLT command <xsl:message>. For example, the source document might contain a value that is not expected by the mapping program. In this case the system can display a message, and, if necessary, terminate processing of the mapping.


Alternatively, you can also call a Java method from your XSLT program, which writes information to the trace using the AbstractTrace Object. For an example, see the XSLT mapping with Java enhancement section.

The PCK does not support the AbstractTrace object.


Messages that are produced using the XSLT command <xsl:message> or the AbstractTrace object are visible in the trace function of the technical monitor (also see: Monitoring XML Messages).


The XLST command <xsl:message> has the following syntax:

<xsl:message terminate=“[yes|no]“>

      <!— Output Message -->


The attribute Terminate determines whether processing of the XSLT program should be terminated (terminate=“yes”) or not (terminate=“no”). In both instances you can view the error message text by using the trace function for a message in monitoring. (provided that you activated the trace function for the Integration Engine).


The following example of a section of an XSLT program is taken from a mapping program with the name Person2Passenger.xsl. The XSLT commands in this section evaluate the current value of a tag from the source document and map the values as follows:

Source Document

Target Document






Mr. or Mrs.

The last instance is an exception for non-interpretable values. To retain this exception in the trace, a message is produced using <xsl:message>:


<xsl:when test="test()=0">Mr.</xsl:when>
<xsl:when test="test()=1">Mrs.</xsl:when>

<xsl:otherwise> Mr. or Mrs.

<xsl:message terminate="no">

Gender has neither value 0 nor 1!
"Mr. or Mrs." was chosen for title.




Since the target field can still be completed appropriately, processing is not terminated (terminate=“no“).

Trace Output

In the technical monitor, the section in the trace for the third instance looks as follows:


<trc1>XSLT transformation: xslt/wsxx/Person2Passenger completed. Gender has neither value 0 nor 1! "Mr. or Mrs." was chosen for title. </trc1>






End of Content Area