ilyn.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> {@link org.milyn.delivery.dom.DOMElementVisitor com.acme.transform.MyJavaOrderItemTransformer}</resource> </resource-config> </smooks-resource-list>
A more complex sample, using 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 {@link org.milyn.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>
Attribute Definitions
- target-profile: A list of 1 or more {@link ProfileTargetingExpression profile targeting expressions}. (supports wildcards "*").
- selector: Selector string. Used by Smooks to "lookup" a resource configuration. This is typically the message fragment name (partial XPath support), but as mentioned above, not all resources are transformation/analysis resources targeted at a message fragment - this is why we didn't call this attribute "target-fragment". This attribute supports a list of comma separated selectors, allowing you to target a single resource at multiple selector (e.g. fragments). Where the resource is a {@link Visitor} implementation, the selectoris treated as an XPath expression (full XPath spec not supported), otherwise the selector value is treated as an opaque value.
Example selectors: - For a {@link Visitor} implementation, use the target fragment name e.g. "order", "address", "address/name", "item[2]/price[text() = 99.99]" etc. Also supports wildcard based fragment selection ("*"). See the User Guide for more details on setting selectors for {@link Visitor} typeresources.
- "#document" is a special selector that targets a resource at the "document" fragment i.e. the whole document, or document root node fragment.
- Targeting a specific {@link org.milyn.xml.SmooksXMLReader} at a specific profile.
- selector-namespace: The XML namespace of the selector target for this resource. This is used to target {@link Visitor} implementations at fragments from aspecific XML namespace e.g. "http://www.w3.org/2002/xforms". If not defined, the resource is targeted at all namespces. Note that since Smooks v1.3, namespace URI-to-prefix mappings can be configured through the "smooks-core" configuration namespace. Then, selectors can be configured with namespace prefixes, removing the need to use the "selector-namespace" configuration.
Resource Targeting Configurations
@author
tom.fennelly@gmail.com
@see SmooksResourceConfigurationSortComparator