Smooks: mixed transformation
standard Feb 20, 2008 9:08 AMHi,
I have yet another question regarding Smooks in ESB, concerning the following scenario:
I want to transform an incoming XML-message into another XML-message.
I already have a rather complex XSLT that does the job, but wanted to try a more modular approach with Smooks,
while keeping each part of the transformation simple and portable.
Because of the structure of input and output I wanted to:
- first apply a rather simple XSLT on the $document node of the input to transform it into the output structure
-> producing a kinda intermediate format already in the right structure, but only with unchanged data from the input
- then do all the complex enrichment stuff via Groovy with that intermediate format
(already in the structure of the final output) on nodes of that intermediate format
-> so producing the final output with data as needed here
I looked at the transformation_ samples and the Smooks tutorials,
but its seems the common use case is the other way around (first enrich, then transform via XSLT),
which really isn't that good an option for me.
When I execute this straight forward, it seems the enrichment doesn't work.
I think this is because of the order in which the transformations beeing applied.
I read that XSLT transformations aren't applied in the "visitBefore" phase per default.
When it comes to the "visitAfter" phase, I think the XSLT-transformation is further down the list than the enrichment stuff (when I understand that demo right: http://milyn.codehaus.org/flash/DOMProcess.html).
So the way I see it, Smooks tries to apply the enrichment transformations to the old input,
which doesn't have the right format for it to work.
I tried adding true to the XSLT transformation conf,
while implementing the enrichment logic inside the visitAfter Method in Groovy, but it didn't work.
I guess I could split the whole process into two complete different actions, (in fact I will try that right now) like in the transform_CSV2XML quickstart, but would prefer to keep it all together, if that is possible.
My question is: is there, and whats is the best way to tell Smooks exactly how I want to have this done, or do I have to split the process into two actions?
Thanks for the help
Andreas