Skip to content

Instantly share code, notes, and snippets.

@svacas
Created February 7, 2012 20:13
Show Gist options
  • Save svacas/1761679 to your computer and use it in GitHub Desktop.
Save svacas/1761679 to your computer and use it in GitHub Desktop.
foreach & xpath
<flow name="process-order">
<http:inbound-endpoint address="http://localhost:8088/process-order"/>
<object-to-string-transformer/>
<foreach expression="#[xpath:/PurchaseOrder/Items/Item]">
<choice>
<when expression="#[xpath:/Item/GiftWrap/text()='true']">
<jms:outbound-endpoint queue="giftwrap.queue" exchange-pattern="one-way"/>
</when>
<otherwise>
<jms:outbound-endpoint queue="regularwrap.queue" exchange-pattern="one-way"/>
</otherwise>
</choice>
</foreach>
<message-properties-transformer scope="invocation">
<add-message-property key="email_to" value="#[xpath://Email]"/>
</message-properties-transformer>
<smtp:outbound-endpoint host="localhost" from="store@mail.com" to="#[variable:email_to]" subject="Your order details">
<expression-transformer expression="#[string:Dear #[xpath://Name], your order total is #[xpath:sum(//Price)].]" />
<email:string-to-email-transformer/>
</smtp:outbound-endpoint>
</flow>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment