This interceptor allows the execution of transformations in the requests and responses through XSLT 2.0 (Extensible Stylesheet Language Transformations).

How it works

The interceptor must be configured with a script, which, in turn, will be executed in the body of the request.

The XSLT interceptor allows transformations from XML only. If the body is in JSON format, it will be automatically converted into XML before XSLT is executed.

Configuring the interceptor

To configure the interceptor, you must include the script to be executed into the Content field.

You can use header, path or query parameters in the execution of the interceptor. To do this, use the variables $header.HEADER_NAME, $queryParam.QUERY_NAME and $pathParam.PATH_NAME.

You can see an example of script below.

The option Abort request if fail can be selected, aborting the call process in case of error when the interceptor runs.


Example of script

Below is an example of a transformation creating a new body into the request, by taking a value from a JSON that was sent by the client and a value for each parameter:

        exclude-result-prefixes="xs xsi xsl"
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/" >
                        <xsl:value-of select="tool/name" />
                        <xsl:value-of select="$header.type" />
                        <xsl:value-of select="$queryParam.id" />

Imagining that the XSLT interceptor is inserted in the flow, it will transform the body of this request:

POST /api?id=123
header type:xml
  "tool": {
    "name": "API Suite",
    "since": "2012"

And this will be the new body created:

<?xml version="1.0" encoding="UTF-8"?>
            <wsx:BodyValue>API Suite</wsx:BodyValue>
Thanks for your feedback!

Share your suggestions with us!
Click here and then [+ Submit idea]