Skip to content

Instantly share code, notes, and snippets.

@svacas
Created February 8, 2012 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svacas/1763191 to your computer and use it in GitHub Desktop.
Save svacas/1763191 to your computer and use it in GitHub Desktop.
foreach & xpath full config
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/3.2/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.2/mule-email.xsd">
<jms:activemq-connector name="JMSConnector"/>
<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>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment