Petals-SE-XSLT 2.4

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

Changes (43)

View Page History
h2. Limitations and warnings

{note}
The transformed content is always the payload from the input message.
{note}

\\
{note}
Do not mistake XSLT services for interceptors.
{note}

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.

\\
The transformed content is always the payload from the input message.
And a chaining service is always required.
{note}
You have to use Java *endorsed* mechanism to work with XSL style sheets of more than 1000 lines.
{note}

This is due to a bug of Xalan. To by-pass it, you have to use a newer version of Xalan (2.7.1 +).
Since the JDK already embeds Xalan, you have to force it to use your version with the [Java *endorsed* mechanism|http://download.oracle.com/javase/6/docs/technotes/guides/standards/index.html].


h1. Creating a XSL Transformation service (Provides modes)

The result of the transformation depends on the XSL style sheet.

\\
If an error occurs during the transformation, then a fault is raised.

{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<xsltFault xmlns="the name space of the invoked operation">
<message>An error message</message>
<details>A stack trace (optional)</details>
</xsltFault>
{code}


h2. The "transformToMtomAttachment" operation

... where _attachmentName_ is the name of the attachment (as specified in the service-unit, or a default value otherwise).

\\
If an error occurs during the transformation, then a fault is raised.

{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<xsltFault xmlns="the name space of the invoked operation">
<message>An error message</message>
<details>A stack trace (optional)</details>
</xsltFault>
{code}

h2. XSL parameters

XSL style sheets supports the definition of parameters.
These parameters can be passed dynamically when executing it.

You can find additional information about it on these web sites:
* http://www.w3schools.com/XSL/el_param.asp
* http://projects.ischool.washington.edu/tabrooks/545/ContentManagement/PassingParameters.htm

\\
The Petals XSLT component allows you to set XSL parameters in two different ways:
* The first one is a static definition in the jbi.xml.
** It allows you to reuse a same XSL style sheet in several services.
** Take a look at the [jbi.xml's parameters|Petals-SE-XSLT 2.4#JBI descriptor] for more information.

* The second way is by setting them at runtime, in the message properties.
** Please, understand that this is not the message payload that defines the parameter values.
** It is the properties of the incoming Petals service (called an exchange). For more details, see Exchange#setInMessageProperty( String, Object ).

Static parameter values may be overriden by dynamic ones.
But only if the static values were defines as _overridable_.
Trying to override a parameter value that is not overridable will result in a fault.


h2. WSDL definitions

The Service-Unit descriptor file ( jbi.xml ) looks like this:
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBI descriptor for the Petals' "petals-se-xslt" component (XSLT).
Originally created for the version 2.4 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
<jbi:provides
interface-name="generatedNs:XsltInterface"
service-name="generatedNs:PersonLocalizer" service-name="generatedNs:Test"
endpoint-name="PersonLocalizerEndpoint"> endpoint-name="TestEndpoint">

<!-- 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> <xslt:stylesheet>transformation.xsl</xslt:stylesheet>

<!-- The following parameter is optional -->
<!-- XSL parameters -->
<xslt:output-attachment-name>TransformedMessage</xslt:output-attachment-name> <generatedNs:xsl-parameters>
<generatedNs:xsl-parameter name="street" overridable="true">
17, rue du Parc
</generatedNs:xsl-parameter>
<generatedNs:xsl-parameter name="city" overridable="false">
Grenoble
</generatedNs:xsl-parameter>
</generatedNs:xsl-parameters>
</jbi:provides>
</jbi:services>
| stylesheet | The relative file path of the XSL style sheet in the service-unit \\ | \- | Yes |
| output-attachment-name | The attachment name to use when the *transformToMtomAttachment* operations is invoked \\ | \- | No |
| xsl-parameters | A list of *xsl-parameter* elements \\ | \- | No |

\\
A *xsl-parameter* element has the following structure:

{code:lang=xml}
<xs:complexType name="XslParameter">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="overridable" type="xs:boolean" default="false" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
{code}

* Its value is a text.
* The *name* attribute must match the name of a XSL parameter.
* The *overridable* attribute defines whether this static value can be overriden by a dynamic value (from an incoming message).


\\
{include:0 CDK SU Provide Configuration}
\\
The component can be configured through its JBI descriptor file, as shown below.
{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">
xmlns:xslt="http://petals.ow2.org/components/xslt/version-2">

<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> class">org.ow2.petals.se.xslt.XsltSe</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>
<petalsCDK:processor-max-pool-size>50</petalsCDK:processor-max-pool-size>
<petalsCDK:ignored-status>DONE_AND_ERROR_IGNORED</petalsCDK:ignored-status>
<petalsCDK:properties-file></petalsCDK:properties-file>
<petalsCDK:notifications>false</petalsCDK:notifications>
<petalsCDK:jbi-listener-class-name>org.ow2.petals.se.xslt.listener.JBIListener</petalsCDK:jbi-listener-class-name> <petalsCDK:jbi-listener-class-name>org.ow2.petals.se.xslt.XsltJBIListener</petalsCDK:jbi-listener-class-name>
</component>
</jbi>{code}