Hi,
Doing some test processes with SimPEL I realized that our assignment was
still pretty basic which leaded to painfully long statements because of the
hierarchical nature of XML. Things like:
customer.payload.ns::customer.ns::firstname =
visitor.payload.ns::customer.ns::fname;
customer.payload.ns::customer.ns::lastname =
visitor.payload.ns::customer.ns::lname;
customer.payload.ns::customer.ns::address.ns::city =
visitor.payload.ns::customer.ns::address.ns::city;
customer.payload.ns::customer.ns::address.ns::zipcode =
visitor.payload.ns::customer.ns::address.ns::zip;
And in the real world those structures usually contain more than 4 elements
:) So to DRY the thing a bit:
with(c = customer.payload.ns::customer, v = visitor.payload.ns::customer) {
c.ns::firstname = v.ns::fname;
c.ns::lastname = v.ns::lname;
with (ca = c.ns::address, va = v.ns::address) {
ca.ns::city = va::ns.city;
ca.ns::zipcode = va.ns::zip;
}
}
Here c, v, ca and va are actually aliases to the original path. I'd also
propose (optional) that a non-existent path used in *with* gets created if
it doesn't exist when a *with* relies on it. So in my previous example if
customer.payload.ns::customer doesn't exist, we create this XML structure
and set it on customer.
So the would get translated to a BPEL equivalent to:
<if>
<condition>!exists(customer.payload.ns::customer)</condition>
<assign>
<from><literal><ns:customer></ns:customer></literal></from>
<to>$customer.payload</to>
</assign>
</if>
(same for visitor.payload but the if body wouldn't execute as it's the
source structure in this example)
<assign>
<copy>
<from>$visitor.payload/ns:customer/ns::fname</from>
<to>$customer.payload/ns:customer/ns::firstname</to>
</copy>
<copy>
<from>$visitor.payload/ns:customer/ns::lname</from>
<to>$customer.payload/ns:customer/ns::lastname</to>
</copy>
(blah blah blah)
</assign>
What do you think? Looks good?
Matthieu