Petals-SE-XSLT

Features

The XSLT Service-Engine allows to transform Petals messages using XSL style sheets.

Each configuration of this component embeds an XSL style sheet.
When such a configuration (i.e. service, i.e. service-unit) is called, it transforms the received message into another one.
The XML payload of the input message is transformed using the XSL style sheet.
The resulting XML document is then returned in the response, either as the payload, or as an attachment.

This component only acts as service provider, not as a service consumer.
In fact, it provides a transformation service.

Additional information about XSLT can be found at http://www.w3.org/TR/xslt.

XSLT Component overview
Contributors
No contributors found for: authors on selected page(s)

Recommended usage

The XSLT component should be used when chaining calls to services whose output and input do not match.
It can also be used to expose XSL transformations as a service, provided that the content to transform is passed in the message payload, and not as attachment.

Taking an example

Let's take the example of two "white pages" services.
These services aims at helping in finding where a person lives (or how to contact this person).

First, you want to call the operation lookup of a service "White Pages".
This operation takes the first name and the family name of a person, and returns a list of phone numbers.
Each phone number is given as a string.

Its prototype looks like

lookup( String firstName, String familyName ) --> String[] phoneNumbers

Do not forget this prototype would be in fact described in the WSDL interface of the service (under an XML shape).

Then, you want to call a service that finds a geographical area (e.g. a city) from a phone prefix.
It is the operation resolve from a service "PrefixToAreaLocalizer".
From a phone prefix, it returns a geographical area.

Its prototype looks like

resolve( int phonePrefix ) --> String areaName

Once again, this prototype is described in the WSDL interface of this second service.

To chain these calls, you have to transform the output of the operation lookup to match the input of the operation resolve.
Indeed, you cannot directly execute

resolve( lookup( "Pierre", "Paul"));

What you will do in your XSL style sheet is extracting the phone prefix from a phone number.
The list go-through will most likely not be made in the XSLT transformation.

There is no more simple way to make the transformation.
In Petals, as well as in most of SOA-related technologies, messages are XML messages.
And for every service, the operations, with their in and out parameters, are described in their WSDL interface.
So, the output message of the resolve operation is an XML (SOAP) message, and the input message of resolve operation is an XML message too.
These XML messages must match the WSDL descriptions of these services.

Obviously, this example is extremely simple.
But the usage remains the same, even with complex XML structures.

XSLT and chaining services

Following our previous example, it appears that chaining and transforming service calls implies using a chaining service (some could say an orchestration service).
This chaining service would do the following calls:

  1. Message from the chaining service to a first service.
  2. Response from the first service to the chaining service (we assume the first service works in InOut message exchange pattern).
  3. Message from the chaining service to the XSLT service.
  4. Response from the XSLT service to the chaining service (the MEP is InOut, always).
  5. Message from the chaining service to a second service. The transformed message is sent to it.
  6. Optional response, depending on the MEP for the second service.

This chaining service can be implemented by a POJO (an home made Java Class) or an Enterprise Integration Pattern (EIP).
It could also be implemented by a BPEL process, but in fact, that would not be a great idea.
BPEL supports the extraction of data from XML messages during the orchestration. When you have a BPEL process, you do not need XSLT. You can use XPath expressions and functions directly in the BPEL. Besides, working with BPEL would require the XSLT configuration to have a WSDL interface while they do not always have one.

Limitations and warnings

The transformed content is always the payload from the input message.
Do not mistake XSLT services for interceptors.

A XSL transformation service cannot transform messages addressed to another service.
Neither to transform attachments, nor to intercept messages on the fly. An orchestration service is required to make the link.
Interceptors would better fit this kind of use case.

To work with XSL style sheets of more than 1000 lines, you have to use another engine than the default one shipped with Java (Xalan 2.6.0 for Java 6 for Petals <5 and Xalan 2.7.0 for Java 7 for Petals >5).

This is due to a bug of Xalan of versions previous than 2.7.1. To bypass it, you have to use a newer version of Xalan (2.7.1 +) or another XSLT engine using a Shared-Library.
Note that for version 2.5 up to 2.7, Saxon is the default engine, so the problem does not arise.

Labels

components-se-family components-se-family Delete
petals petals Delete
component component Delete
se se Delete
xslt xslt Delete
home home Delete
user user Delete
guide guide Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.