Powered By

Free XML Skins for Blogger

Powered by Blogger

Friday, January 16, 2009

Error Handling in XSLT

Use

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 . 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.

Note

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

The PCK does not support the MappingTrace object.

Integration

Messages that are produced using the XSLT command or the MappingTrace object are visible in the trace function of the technical monitor (also see: Structure linkMonitoring XML Messages).

Features

The XLST command has the following syntax:

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

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).

Example

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

0

Mr.

1

Mrs.

(Other)

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 :

Mr.
Mrs.

Mr. or Mrs.

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:

ENTER" func="CL_XMS_PLSRV_MAPPING~ENTER_PLSRV" />

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

EXIT" func="CL_XMS_PLSRV_MAPPING~ENTER_PLSRV" />

No comments:

Archives