Creating CDATA structures in SAP PI using XSL/XSLT

I had a challenge with creating some CDATA elements for a customer.

In XML you can use CDATA if you have some escaped content in some of your document. If there is the CDATA start and end tag then it does not have any problem with containing characters like “< >” . These characters will normally create problems with XML because it is what is expected in the formatting.

Let’s say we have a document that looks like the following XML document.

As we can see the text in this document is escaped, so a potential recipient needs to escape it to be able to display the result.

And we want it to be transformed into. As seen the %lt; is converted into <, so the content can be displayed as HTML really easy.

In XSL it can be done in the following way.

In this example we are using the cdata-section-elements on the output target. This command tells parser to escape the result in the text element with cdata. This works when I’m doing XSL standalone SAPXMLTOOLKIT. Unfortunately it did not work when I was testing it at the PI system. So I had to find another solution. I don’t know if it was just me, or this feature is not supported.

The match “@*|node()” area makes sure that both attributes and value elements are copied. If only “*” was used then there the attributes would not be copied.

I therefore had to try again. It is not that much different.

In this section we matched the text element. The element is copied with the copy statement.

The text is escaped with the disable-output-escaping, to make sure that the values is not escaped. To make this work, the first < in the CDATA had to be using an escaped value. If not then all the content in the CDATA section would just be copied to the result, it will not be evaluated.

I hope that this is helpful for you to make get more knowledge about what is going on.

Related Posts:

The different ways of archiving messages on SAP PI

There seems to be some misunderstanding of what the different types of archiving is. I therefore have decided to create a video where I talk about the differences between them. Hopefully it will clear some of the misunderstanding.

I see that there are two different types of archiving

  • Technical
  • Content archiving


This part is where messages is saved technical. It is the standard form of archiving in SAP Process Integration. Technical archiving is where all the runtime messages from SXI_MONITOR and the corresponding tables from the adapter framework are removed. This happens to conserve space in the database and ensure the PI can run fast enough.


This part is to make sure the content sent is archived. This is by extracting the message and make sure it can be recovered.

There is a 15 minutes video about the content.

For more information about the SAP PI Archiving solution see

Related Posts: