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.
Resource Configuration Properties
- selector: Selector string. Used by Smooks to "lookup" a resource configuration. This is typically the message fragment name, 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".
- selector-namespace: The XML namespace of the selector target for this resource. This is used to target ContentDeliveryUnits at XML elements from a specific XML namespace e.g. "http://www.w3.org/2002/xforms". If not defined, the resource is targeted at all namespces.
- target-profile: A list of 1 or more profile targeting expressions. (supports wildcards "*").
- The target fragment name (e.g. for HTML - table, tr, pre etc). This type of selector can be contextual in a similar way to contextual selectors in CSS e.g. "td ol li" will target the resource at all "li" elements nested inside an "ol" element, which is in turn nested inside a "td" element. See sample configurations above. Also supports wildcard based fragment selection ("*").
- "$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 SmooksXMLReader at a specific profile. See the csv-to-xml and edi-to-xml tutorials.
XML Based Configuration
Smooks can be manually configured (through code), but the easiest way of working is through XML.
Note that it is not using any profiling. The resource-config element maps directly to an instance of this class.
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)).
For more examples, check out the tutorials.
Java Based Configuration