XSLT Transformation

Overview

Extensible Stylesheet Language Transformations (XSLT) is a declarative, XML-based language used to transform XML documents into other XML documents. An XSL stylesheet is used to transform an XML document into another document type. The stylesheet defines how elements in the XML source document should appear in the resulting XML document.

The API Gateway can convert XML data to other data formats using XSL files. For example, an incoming XML message adhering to a specific XML schema can be converted to an XML message adhering to a different schema before it is sent to the destination Web Service.

This type of conversion is especially valuable in the Web Services arena, where a Web Service might receive SOAP requests from various types of clients, such as browsers, applications, and mobile phones. Each client might send up a different type of SOAP request to the Web Service. Using stylesheets, the API Gateway can then convert each type of request to the same format. The requests can then be processed in the same fashion.

Enter an appropriate name for this filter in the Name field, and configure the following tabs.

Stylesheet Location

Select an XSL stylesheet from the Stylesheet Location drop-down list, which is populated with the contents of the Stylesheet Library. You can import a new stylesheet into the library by clicking the View/Import button, and the Add button on the Stylesheet Library dialog.

You can modify existing stylesheets in the XSLT Contents text area, and then update them in the API Gateway configuration by clicking the Update button.

Stylesheet Parameters

You can pass parameters to an XSL stylesheet using specified values in <xsl:param> elements. These values are then used in the templates defined throughout the stylesheet.

Using the XSLT Transformation filter, you can pass the values of message attributes to the configured stylesheet. For example, you can take the value of the authentication.subject.id message attribute, pass it to the configured XSL stylesheet, and then output this value to the result produced by the conversion.

To use this feature, select the Use Message Attributes as Stylesheet Parameters checkbox, and specify the message attribute to pass to the stylesheet by clicking the Add button.

The following example from an XSL stylesheet that uses parameters shows how to configure this:

<xsl:param name="authentication.subject.id"/>
<xsl:param name="authentication.issuer.id"/>

To pass the corresponding message attribute values to the stylesheet, you must add the authentication.subject.id and authentication.issuer.id message attributes to the Message Attributes to use table.

[Important] Important

The name of the specified parameter must be a valid API Gateway message attribute name, and there must be an equivalent parameter name in the stylesheet.

Advanced

Complete the following fields on this tab:

Provider Class Name:

Enter the fully qualified name of the XSLT provider class of the XSLT library that you want to use. This class must be added to the API Gateway's classpath. If this field is blank, the default provider is used.

The simplest way to add a provider class to the API Gateway's classpath is to drop the required JAR file into the PRODUCT_HOME/ext/lib directory, where PRODUCT_HOME refers to the root of your API Gateway installation.

Result will be XML:

You can convert an incoming XML message to other data formats. Select this option if the result of the XSLT conversion is always XML. If not, the content-type of the result document depends on the output method of the XSLT stylesheet. For example, if the stylesheet specifies an output method of HTML (<xsl:output method="html">), this field should be left blank so that the API Gateway can forward on the HTML output document to the target Web Service.

Do not change the content type header:

You can select whether to change the HTTP Content-Type header in this XSLT transformation. This setting is selected by default, so the content type is preserved.