Creating simple transformations

In this recipe, we will see how we can create a simple transformation comprising of literal texts and no data root. We will use the transaction XSLT_TOOL.

How to do it...

We will carry out the following steps:

  1. Call the transaction XSLT_TOOL. Enter a suitable transformation name in the field provided (we give the name zst6_first). Then, press the Create button.
    How to do it...
  2. This will display a dialog box asking you for the description and the type of the transformation. Enter a short description in the field provided. From the Transformation Type list box, make sure to choose the option Simple Transformation. Then, press Enter.
    How to do it...
  3. From the screen that appears, choose the SourceCde tab. You will find the source code editor filled with the basic code.
    How to do it...
  4. We will now write the code for our "simple" simple transformation. We will delete the root element. Within the template, we will add literal elements along with the necessary literal texts with and without identification. We create a literal element X0 that contains the literal elements X1 and X2. After the addition of the lines, the code appears as shown in following screenshot:
    How to do it...

How it works...

We created a simple transformation. It contains no root element, meaning that it can be passed any ABAP data object when called from an ABAP program.

When the transformation is serialized, the resulting XML code looks like the following code:

<X0>
    <X1>  my transformation first line </X1>
    <X2>  second line </X2>
</X0>

The literal element X1 contains literal text without identification, whereas X2 contains text with identification defined within <tt:text> and </tt:text>.

There's more...

To better understand the literal text with the identification feature, consider the following example:

There's more...

We create an element X2 without identification and an element X3 with identification. Both contain blank spaces. The resulting XML string (as seen in the debugger) will be as follows:

There's more...

For element X3, the white spaces are preserved, whereas for X2 they are not.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.107.85