...
ServiceMix Saxon
The servicemix-saxon ServiceMix Saxon component is a standard JBI Service Engine for XSLT / XQuery. This component is based on Saxon and supports XSLT 2.0 and XPath 2.0, and XQuery 1.0.
Warning | ||
---|---|---|
| ||
Due to a bug in the latest release of Saxon, the |
...
Maven Archetype
You can use Maven servicemix-saxon
...
Installation
Installing the servicemix-saxon component can be done in several ways:
- drop the installer zip in an hotdeploy directory monitored by ServiceMix
- using ant tasks
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.
Service Unit packaging
A service unit will typically consist in:
- an
xbean.xml
configuration file - the associated xslt / xquery document
Content of xbean.xml file to be packaged as a SU
...
<beans xmlns:saxon="http://servicemix.apache.org/saxon/1.0">
... add endpoints here ...
</beans>
-service-unit archetype to create a Saxon service unit:
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-saxon-service-unit \
-DarchetypeVersion=2010.01 \
-DgroupId=your.group.id \
-DartifactId=your.artifact.id \
-Dversion=your-version
|
Endpoints Configuration
Using servicemix-saxon in a ServiceMix xml configuration file
...
XSLT Endpoint
The XSLT endpoint can be used to apply an XSLT stylesheet to the incoming exchange and will return the transformed result as the output message.
...
Info | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Using properties and parameters
All properties defined on the JBI exchange and input JBI message will be available for use inside the XSLT stylesheet as parameters.
In addtion to those properties and the one specified in the parameters
property on the endpoint, the following objects are also available:
...
Code Block | ||
---|---|---|
| ||
<saxon:xslt service="test:xslt-params" endpoint="endpoint" resource="classpath:parameter-test.xsl"> <property name="parameters"> <map> <entry key="stringParam" value="cheeseyCheese"/> <entry key="integerParam"> <bean class="java.lang.Integer"> <constructor-arg index="0" value="4002"/> </bean> </entry> </map> </property> </saxon:xslt> |
XSLT Proxy
One common use case is the need to transform a request coming from a service and send it to another service and do the same with the response. A simple example is the need to translate the request and responses between two SOAP endpoints. Such a use case could be implemented using two XSLT endpoints and an EIP StaticRoutingSlip. However, there are some drawbacks, as the operation is lost in the process, and a static routing slip can not be used to process InOnly exchanges.The 4.0 version of servicemix-saxon provides such a feature in a single endpoint:
Code Block | ||
---|---|---|
| ||
<saxon:proxy service="test:proxy" endpoint="endpoint" resource="classpath:transform-in.xsl" outResource="classpath:transform-out.xsl" faultResource="classpath:transform-fault.xsl"> <saxon:target> <saxon:exchange-target service="test:echo" /> </saxon:target> </saxon:proxy> |
Info | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
XQuery
...
Endpoint
The XQuery endpoint can be used to apply a selected XQuery to the input document.
...