A "Smooks Resource" is anything that can be used by Smooks in the process of analyzing or transforming a data stream. They could be pieces of Java logic (DOMElementVisitor), some text or script resource, or perhaps simply a configuration parameter.
Example selectors:
Smooks can be manually configured (through code), but the easiest way of working is through XML.
Basic Sample:
Note that it is not using any profiling. The resource-config element maps directly to an instance of this class.
<?xml version='1.0'?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
<resource-config selector="order order-header">
<resource type="xsl">/com/acme/transform/OrderHeaderTransformer.xsl</resource>
</resource-config>
<resource-config selector="order-items order-item">
<resource>com.acme.transform.MyJavaOrderItemTransformer</resource>
</resource-config>
</smooks-resource-list>
|
More Complex Sample:
This sample uses profiling. So resource 1 is targeted at both "message-exchange-1" and "message-exchange-2", whereas resource 2 is only targeted at "message-exchange-1" and resource 3 at "message-exchange-2" (see Smooks.createExecutionContext(String)).
<?xml version='1.0'?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
<profiles>
<profile base-profile="message-exchange-1" sub-profiles="message-producer-A, message-consumer-B" />
<profile base-profile="message-exchange-2" sub-profiles="message-producer-A, message-consumer-C" />
</profiles>
(1) <resource-config selector="order order-header" target-profile="message-producer-A">
<resource>com.acme.transform.AddIdentityInfo</resource>
</resource-config>
(2) <resource-config selector="order-items order-item" target-profile="message-consumer-B">
<resource>com.acme.transform.MyJavaOrderItemTransformer</resource>
<param name="execution-param-X">param-value-forB</param>
</resource-config>
(3) <resource-config selector="order-items order-item" target-profile="message-consumer-C">
<resource>com.acme.transform.MyJavaOrderItemTransformer</resource>
<param name="execution-param-X">param-value-forC</param>
</resource-config>
</smooks-resource-list>
|
For more examples, check out the tutorials.
TODO!!