Format XML in @rawstring Field after Filtering Data

Format XML in @rawstring field after filtering the data using the xml:prettyPrint() function

Query

flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result
logscale
#type=SOAP
| account=123
| xml:prettyPrint()

Introduction

The data type SOAP (Simple Object Access Protocol) stores a text string along with an identifier of the character set used in the string. If the character set used in the string is UTF-8, the string may be passed to Transformation Server unmodified.

The xml:prettyPrint() function can be used to format the XML in the output string (the filtered data) for improved readability.

It is recommended to apply xml:prettyPrint() after filtering your data at the end of the query. This prevents unnecessary formatting of data that will be discarded.

In this example, the xml:prettyPrint() function is used to format the filtered SOAP messages in the output string.

Note that if no field is specified, the @rawstring field will be formatted.

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    #type=SOAP

    Filters for all events of the data type SOAP.

  3. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    | account=123

    Filters for strings where the field account matches the value 123. It narrows the scope to a specific account's SOAP messages.

  4. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result style 2 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    | xml:prettyPrint()

    Takes the filtered SOAP messages (which are in XML format), and formats the XML content in the @rawstring field for better readability.

    In this example, all the default values for the parameters field, step, width and strict are used.

  5. Event Result set.

Summary and Results

The query is used to format rawstrings into valid XML, in this case retrieved SOAP messages from account 123. This is useful, for example, when analyzing specific SOAP messages in detail.

Note that the xml:prettyPrint() function can be used on any XML content - not just limited to SOAP messages, but also REST XML responses, XML configuration files, XML logs and any other XML formatted data.

"Pretty printing" XML can be an expensive operation and it is recommended only to perform this after filtering the data (at the end of the query), so that only filtered data is formatted.