Skip to end of metadata
Go to start of metadata

Smooks should not be thought as an alternative to XSLT, or any other XML transformation/analysis tool. The idea behind Smooks is to provide a framework within which transformations can be applied across a message set, using the tools and languages most appropriate to the type of transformations required (that tool may well be XSLT).

Smooks is a framework that allows you mix and match tools and languages within the context of a single transformation e.g. you can easily use XSLT to transform one part of a message, while at the same time use pure Java (or Groovy etc) to transform another part. You can even combine the respective powers of XSLT and Java to simplify your XSLT transformations.

Basically, Smooks tries to free you from being locked into one way of performing data transformation (XML and non-XML).

All that said, it's still useful to make some comparisons between Smooks and XSLT. This should help frame Smooks in terms of "what it is".

The 3 main points of comparison

  1. Smooks is a non-templating solution. By this we mean that it doesn't "manufacture" a completely new XML document using a source message instance as input. Instead, Smooks visits the source message instance and transforms the source inline i.e. no new document created. XSLT constructs a completely new document while performing the transformation, even if the transformation only modifies a single document node.
  2. The Smooks Transformation model focuses its attention at the document fragment level. With Smooks, you build a catalog/database of "sub-transformations" using the tools or languages most appropriate to each sub-transformation (Java, XSLT etc). You then declaritively "target" these sub-transformations at specific document/message fragments based on message profiles (of course, the fragment can include as much or little of the message as is appropriate). This means that for each message, the transformation is dynamically constructed based on the set of profiles associated with the message. With XSLT you manually pull together all relevant stylesheets by importing them into a top level stylesheet. You then target the top level stylesheet at the whole Document, making pure XSLT transformations more of a batch type process - hence the notion of "transformation pipelines" is very common where XSLT is in use.
  3. Smooks currently only supports DOM based Transfroms. However, we have concrete plans to support Stream and SAX based transforms. Hopefully this is not too far away.

So if Smooks is a non-templating solution, how can XSLT be used as part of a Smooks transformation?

Smooks supports XSLT through the Smooks Templating Cartridge. However, Smooks applies XSLT at the message fragment level. So in terms of the overall document/message, Smooks is a non-templating solution, but Smooks does not prevent you from performing templating operations at a message fragment level.

  • No labels