Petals-SE-XSLT

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (29)

View Page History

The XSLT Service-Engine allows to transform Petals messages using XSL style sheets.
Each configuration of this component embeds an XSL style sheet. When this configuration (or service, or 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.

\\
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.

\\
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

{code:lang=javascript}
\\
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

{code:lang=java}

\\
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.

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

h2. Limitations

Configurations for this component cannot be used as a proxy to call other services.
Neither to transform attachments, nor to intercept messages on the fly.
Interceptors would better fit this kind of use case.
However, it is possible to define one. This WSDL must define two operations, being *transform* and *transformToAttachment*.
These two operations are the ones the component supports. The associated name space (WSDL operation names are QNames) depends on the version of the component.
For the versions 2.3 of the XSLT component, this name space is [http://petals.ow2.org/components/xslt/version-2]

\\
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<jbi
version="1.0"
xmlns='http://java.sun.com/xml/ns/jbi'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5">

<component type="service-engine">
<identification>
<description>A Xslt Service Engine</description>
</identification>

<component-class-name description="Xslt Component class">org.ow2.petals.se.xslt.XsltComponent</component-class-name>
<component-class-path><path-element/></component-class-path>
<bootstrap-class-name>org.ow2.petals.component.framework.DefaultBootstrap</bootstrap-class-name>
<bootstrap-class-path><path-element/></bootstrap-class-path>

<petalsCDK:acceptor-pool-size>3</petalsCDK:acceptor-pool-size>
<petalsCDK:processor-pool-size>10</petalsCDK:processor-pool-size>
The Service Unit descriptor file ( jbi.xml ) looks like this:
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<!--
JBI descriptor for the Petals' "petals-se-xslt" component (XSLT).
Originally created for the version 2.3 of the component.
-->
<jbi:jbi version="1.0"
xmlns:generatedNs="http://petals.ow2.org/components/xslt/version-2"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xslt="http://petals.ow2.org/components/xslt/version-2">

<!-- Import a Service into Petals or Expose a Petals Service => use a BC. -->
<jbi:services binding-component="false">

<!-- Import a Service into Petals => provides a Service. -->
<jbi:provides
interface-name="generatedNs:XsltInterface"
service-name="generatedNs:PersonLocalizer"
endpoint-name="PersonLocalizerEndpoint">

<!-- CDK specific elements -->
<petalsCDK:timeout>30000</petalsCDK:timeout>
<petalsCDK:forward-attachments>false</petalsCDK:forward-attachments>
<petalsCDK:wsdl>XsltService.wsdl</petalsCDK:wsdl>

<!-- Component specific elements -->
<xslt:stylesheet>fromTo.xsl</xslt:stylesheet>

<!-- The following parameter is optional -->
<xslt:output-attachment-name>TransformedMessage</xslt:output-attachment-name>
</jbi:provides>
</jbi:services>

The service unit must contain the XSL style sheet.
It is also highly recommended to provide a WSDL description for this service.
This WSDL is not mandatory, but not providing it will prevent your service from interacting with other Petals services and components.

+ META-INF
- jbi.xml
+ <XSL style sheet>.xsl
+ customFunctions.jar (optional)
{noformat}

{column}

{column:width=350px}
{panel:title=Table of contents}{toc}{panel}