The XsltComponent will perform an XSLT transformation of an inbound NormalizedMessage and generate an output message as a NormalizedMessage.

If the component is given an InOut message exchange, then the 'out' message is used. Otherwise if an InOnly is used then the component will create a new InOnly message exchange for the result of the transformation.

The transformation can be configured using any JAXP Source or using a Spring Resource to the XSL file.

Example

There is an example which demonstates a pipeline from a message source, to a transformation, to send the message along with tracing the operation.

Receiving the message from a JMS topic

<sm:activationSpec componentName="myJmsReceiver" service="foo:myJmsReceiver" destinationService="foo:transformer">
  <sm:component><bean class="org.apache.servicemix.components.jms.JmsReceiverComponent">
    <property name="template">
      <bean class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
          <ref local="jmsFactory"/>
        </property>
        <property name="defaultDestinationName" value="test.org.apache.servicemix.components.xslt.source"/>
        <property name="pubSubDomain" value="true"/>
      </bean>
    </property>
  </bean></sm:component>
</sm:activationSpec>

 

Transforming the message using XSLT

<sm:activationSpec componentName="transformer" service="foo:transformer" destinationService="foo:transformedSender">
  <sm:component><bean class="org.apache.servicemix.components.xslt.XsltComponent">
    <property name="xsltResource" value="classpath:org/apache/servicemix/components/xslt/transform.xsl"/>
  </bean></sm:component>
</sm:activationSpec>

 

Sending the result to a different JMS topic

<sm:activationSpec componentName="myJmsSender" service="foo:myJmsSender">
  <sm:component><bean class="org.apache.servicemix.components.jms.JmsSenderComponent">
    <property name="template">
      <bean class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
          <ref local="jmsFactory"/>
        </property>
        <property name="defaultDestinationName" value="test.org.apache.servicemix.components.xslt.source"/>
        <property name="pubSubDomain" value="true"/>
      </bean>
    </property>
  </bean></sm:component>
</sm:activationSpec>

 

Subscribing to the topic and pipelining it to a trace component to demonstrate the pipeline working

<sm:activationSpec componentName="jmsTrace" service="foo:jmsTrace" destinationService="foo:trace">
  <sm:component><bean class="org.apache.servicemix.components.jms.JmsReceiverComponent">
    <property name="template">
      <bean class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
          <ref local="jmsFactory"/>
        </property>
        <property name="defaultDestinationName" value="test.org.apache.servicemix.components.xslt.result"/>
        <property name="pubSubDomain" value="true"/>
      </bean>
    </property>
  </bean></sm:component>
</sm:activationSpec>

<sm:activationSpec componentName="trace" service="foo:trace">
  <sm:component><bean class="org.apache.servicemix.components.util.TraceComponent"/></sm:component>
</sm:activationSpec>