of the same type as the one that arrived to foreach.
payload is converted to DOM. This allows operating on the nodes and
reflecting the changes on the original message. The message is
converted to string again when foreach ends.
Something similiar can be implemented for the JSON enrichment case.
Let me know your thoughts.
Post by Daniel FeistHi Ross,
This example should work as long as xpath-node expression evaluator is used
instead of xpath, we haven't tried this though. Also there are currently no
elements to add/remove XML attributes/elements declaratively in your
configuration file.
The first thing we'll do is attempt to implement this type of use case with
foreach, because you are right I'd expect to be able to do the same.
Split-aggregate would be used if I wanted to do something similar but for
each item create an object and then aggregate these new objects into a
result. Split-aggregate is really the same as using a splitter/aggregator
pair, just simpler to understand/use.
Dan
Thanks for the demos today guys. I want o comment on the ForEach and
Split-agregate spec, but comments are not enabled on the wiki (which is
My pushback on ForEach is all around giving the use a clear mental model of
when to use ForEach and when to split -aggregate. The separation is not
clear right now, which makes it hard to say whether ForEach is the right
implementation as it stands. I'm not sure yet if ForEach is suitable for
Since ForEach is ByRef I can't change the outer structure of the message,
but I can still change the inner structure with ForEach, so in theory I can
do enrichment and maintain structure in the message. I do think this type
<PO>
<customer>
.....
</customer>
<order-items>
<item>
<sku>34934938498934</sku>
</item>
<item>
<sku>59677477372722</sku>
</item>
</order-items>
</PO>
I can iterate over each item, but there are many scenarios where I want to
enrich the data, ie. to look up product description based on SKU.
<foreach expression="#[xpath:/PO/order-items/item]">
<enricher target="#[variable:description]">
<foo:get-item-description sku="#[xpath:/item/sku]"/>
</enricher>
<mxml:add-element name="description" value="#[variable:description]"/>
</enricher>
</foreach>
<PO>
<customer>
.....
</customer>
<order-items>
<item>
<sku>34934938498934</sku>
<description>A sprocket</description>
</item>
<item>
<sku>59677477372722</sku>
<description>A gromit</description>
</item>
</order-items>
</PO>
You can see a user thinking this should work as a way of doing enrichment
using ForEach. I'm not saying this should be possible or not, we just need
to see the use cases side by side to order to understand how we give the
user the right mental model for working with ForEach.
Also, where does data mapper come into this?
If <foo:get-item-description> calls out to a db, this might just be a
mapping look up. If this is a web service call, DM doesn't make as much
sense.
All the use cases need to be defined up front and then assessed against what
we think ForEach, Splitter - Aggregate and DM should be used for. We can't
make good decisions considering just a subset of use cases. Bear in mind we
don't need to support every use-case we can think of and should be striking
out the edge cases (avoid feeding the software monster).
Cheers,
Ross Mason
CTO, Founder
MuleSoft Inc.
@rossmason
Try iON: integration Platform as a Service http://muleion.com
http://mulesoft.com | http://blogs.mulesoft.org
Post by Daniel FeistForeach encapsulates a splitter yes, but I don't think we should expose
the name "splitter" anywhere, want to keep things as simple as possible and
not allow any confusion. Most non-advanced users will see foreach and
splitter as two completely different things.
If i had to give it a more specific name it would be iterableExpression or
listToIterateExpression or something like that consistent with the foreach
concept.
But IMO just expression is fine, I think its fairly obvious that its there
to select what you want to iterate over and especially when accompanied with
documentation.
Dan
Post by Ken YagenSantiago,
Attribute name expression makes sense for instance in
expression-transformer element, since the element name already tells you
what's the expression for.
I think it's a good idea to call it splitterExpression. The same is done
for idempotent-redelivery-policy, the attribute idExpression is to set the
expression for the id generation. Having attribute names like those makes
mule configuration easier to understand.
Pablo.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email