
h2. The "transformToMtomAttachment" operation
The fully qualified name of this operation is:
* Name space URI: any URI, provided it is not null (e.g. *{html}http://petals.ow2.org/components/xslt/version-2{html}\*)
* Local part: *transformToMtomAttachment*
This operation only supports the *InOut* message exchange pattern (MEP).
When invoking this operation, you must call it using its fully qualified name.
This operation cannot be described in a WSDL, because of the result it returns.
Here is the execution flow for this operation:
# The received message is transformed with the XSL style sheet.
# The transformation result is attached to the response in MTOM mode.
The attachment is not sent in MTOM mode.
The result of the transformation has always the same shape.
{code:lang=xml}
<<attachedTransformResponse xmlns="..." xmlns:xop="http://www.w3.org/2004/08/xop/include">
<fileContent>
<xop:include href="cid:attachmentName" />
</fileContent>
<<attachedTransformResponse>
{code}
... 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]
* [http://www.xml.com/pub/a/2001/02/07/trxml9.html]
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 parameters|Petals-SE-XSLT 2.5.x-2.6.x#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.
{info}Remember, XSL parameters are declared with a *param* element in the XSL style-sheet.
A XSL parameter can be global (declared as a root element) or local (declared inside a template).
The value of a XSL parameter can be retrieved with *$parameter_name* or *\{$parameter_name\}*, depending on the parameter usage.{info}
h2. XSLT transformer processor
The Petals XSLT component enables you to choose the XSLT processor.
By default, Saxon is used as XSLT engine. It is possible to select another XSLT processor for a specific SU than the default one by:
* installing a shared library containing the XSLT processor to use,
* setting this shared library into the Petals XSLT component,
* *AND* [the XSL transformer factory classname parameter|#xslt-engine-factory-class-name] in the jbi.xml of the SU.
{tip}
To set the shared library to use into the Petals XSLT component, use the [Petals maven plugin|Maven Petals Plug-in 2.1.4+].
{tip}
h2. XSLT efficiency
A pool of XSL transformers is created for each SU at its start in order to obtain better performance. [Two parameters|Petals-SE-XSLT 2.5.x-2.6.x#xslt-engine-pool-size] enable you to set the number of XSL transformers to create at the start of the SU and the maximum number of transformers to instantiate. If all the XSL transformers are used (because of receiving a lot of requests concurrently on the service), the request blocks until a transformer is released.
h2. WSDL definitions
Configurations (service-units) for the XSLT component do not have, in general, a WSDL definition.
However, it is possible to define one which describes the *transform* and "transformToMtomAttachment" operations.
The input and output messages for the *transform* operation are related to the XSL style sheet.
In fact, the input message should be the output message of the previous chained service (the one whose output must be transformed).
And the output message should be the input message of the next chained service.
The input message for the *transformToMtomAttachment* operation is related to the XSL style sheet.
In fact, the input message should be the output message of the previous chained service (the one whose output must be transformed). The WSDL message should reference a XML element of the same type than the input message of the *transform* operation.
And the output message should describe the MTOM structure that was documented above. In this structure, _fileContent_ is a base64Binary element and the _xop:include_ element does not appear.
As said at the beginning of this section, WSDL are not mandatory though. Typically, integration use cases do not require one. But not having one is bad practice in SOA.
Your XSLT service is then not reusable, and no one else will ever use it unless you give him the XSL style sheet to determine the expected input and output.
{tip}
Beginning by creating a WSDL, and then continuing by the XSL style sheet appears as the best practice to have.
{tip}
h2. JBI descriptor