You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ode.apache.org by Matthieu Riou <ma...@offthelip.org> on 2007/12/19 19:14:09 UTC

[SimPEL] Adding with

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

Re: [SimPEL] Adding with

Posted by Matthieu Riou <ma...@offthelip.org>.
On Dec 19, 2007 10:56 AM, Alex Boisvert <bo...@intalio.com> wrote:

> On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
> >
> > 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;
> >   }
> > }
>
>
> I think aliasing is a good idea, although I think we can achieve it using
> functions and possibly currying instead of adding syntax to the language.
> How about,
>
> c = xpath(customer.payload.ns::customer)
> v = xpath(visitor.payload.ns::customer)
>
> c.ns::firstname = v.ns::fname
> c.ns::lastname = v.ns::lname
>
> ca = xpath(c, c.ns::address)
> va = xpath(v, v.ns::address)
>
> ...
>

So far we've stick with the original definition and structure of BPEL
variables (they only hold XML) and functions have been either external or
defined in very specific places. Doing this would make them something
different entirely. I'm not sure we're ready to deal with closures and
currying just yet.


>
> 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>
>
>
> This has the side-effect of wiping the rest of the $customer.payload
> content.
>

Which is why I've said this behavior would be optional. I just haven't
figured out the syntax for this option yet :)

Matthieu


>
> alex
>

Re: [SimPEL] Adding with

Posted by Alex Boisvert <bo...@intalio.com>.
On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
>
> 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;
>   }
> }


I think aliasing is a good idea, although I think we can achieve it using
functions and possibly currying instead of adding syntax to the language.
How about,

c = xpath(customer.payload.ns::customer)
v = xpath(visitor.payload.ns::customer)

c.ns::firstname = v.ns::fname
c.ns::lastname = v.ns::lname

ca = xpath(c, c.ns::address)
va = xpath(v, v.ns::address)

...

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>


This has the side-effect of wiping the rest of the $customer.payload
content.

alex

Re: [SimPEL] Adding with

Posted by Tammo van Lessen <tv...@gmail.com>.
Matthieu Riou wrote:
> 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;
>   }
> }

Awesome!

...
> 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>
...
hehe, this is probably the first grammar ever that has a "formal" proof
in BPEL ;)

Cheers,
  Tammo

Re: [SimPEL] Adding with

Posted by Matthieu Riou <ma...@offthelip.org>.
On Dec 19, 2007 1:47 PM, Assaf Arkin <ar...@intalio.com> wrote:

> On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
> >
> > On Dec 19, 2007 11:45 AM, Assaf Arkin <ar...@intalio.com> wrote:
> >
> > > On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
> > > >
> > > > 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.
> > >
> > >
> > > If you meant for it to exist, it would be there.  If you didn't mean
> for
> > > it
> > > to exist, then I would expect it to fail.  The idea of data created
> > > magically is too much black magic for me.
> > >
> >
> > I agree. And still think this is needed. The selection failures on
> > initialized variables is the single most encountered problem in the ODE
> > user
> > mailing list. And I don't even count those who tried their first process
> > to
> > get a feeling of it, got their first selection failure and then went to
> > something else without bothering abut subscribing to the mailing-list.
> >
> > I just *know* that people will write stuff like the following snippet
> > without having initialized the customer structure.
> >
> >   customer.payload.ns::customer.ns::firstname =
> > visitor.payload.ns::customer.ns::fname;
> >
> > Now maybe that should be part of something else and not included in
> > *with*.
> > I just don't know what that something else should be.
>
>
> This won't work in any language I know, take Ruby for example:
>
> msg['customer']['firstname'] =  'Assaf'
>
> will complain that it doesn't understand calling [] on nil, which is
> easily
> fixed:
>
> msg['customer'] ||= {}
>

Actually, giving it more thoughts, we could devise a static check at compile
time that would detect most of these mistakes. A helpful message could
probably go a long way to helping BPEL noobs.

Matthieu


>
> Assaf
>
> Matthieu
> >
> >
> >
>

Re: [SimPEL] Adding with

Posted by Assaf Arkin <ar...@intalio.com>.
On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
>
> On Dec 19, 2007 11:45 AM, Assaf Arkin <ar...@intalio.com> wrote:
>
> > On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
> > >
> > > 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.
> >
> >
> > If you meant for it to exist, it would be there.  If you didn't mean for
> > it
> > to exist, then I would expect it to fail.  The idea of data created
> > magically is too much black magic for me.
> >
>
> I agree. And still think this is needed. The selection failures on
> initialized variables is the single most encountered problem in the ODE
> user
> mailing list. And I don't even count those who tried their first process
> to
> get a feeling of it, got their first selection failure and then went to
> something else without bothering abut subscribing to the mailing-list.
>
> I just *know* that people will write stuff like the following snippet
> without having initialized the customer structure.
>
>   customer.payload.ns::customer.ns::firstname =
> visitor.payload.ns::customer.ns::fname;
>
> Now maybe that should be part of something else and not included in
> *with*.
> I just don't know what that something else should be.


This won't work in any language I know, take Ruby for example:

msg['customer']['firstname'] =  'Assaf'

will complain that it doesn't understand calling [] on nil, which is easily
fixed:

msg['customer'] ||= {}

Assaf

Matthieu
>
>
>

Re: [SimPEL] Adding with

Posted by Matthieu Riou <ma...@offthelip.org>.
On Dec 19, 2007 11:45 AM, Assaf Arkin <ar...@intalio.com> wrote:

> On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
> >
> > 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.
>
>
> If you meant for it to exist, it would be there.  If you didn't mean for
> it
> to exist, then I would expect it to fail.  The idea of data created
> magically is too much black magic for me.
>

I agree. And still think this is needed. The selection failures on
initialized variables is the single most encountered problem in the ODE user
mailing list. And I don't even count those who tried their first process to
get a feeling of it, got their first selection failure and then went to
something else without bothering abut subscribing to the mailing-list.

I just *know* that people will write stuff like the following snippet
without having initialized the customer structure.

  customer.payload.ns::customer.ns::firstname =
visitor.payload.ns::customer.ns::fname;

Now maybe that should be part of something else and not included in *with*.
I just don't know what that something else should be.

Matthieu


> Assaf
>
>
> 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
> >
>
>
>
> --
> CTO, Intalio
> http://www.intalio.com
>

Re: [SimPEL] Adding with

Posted by Assaf Arkin <ar...@intalio.com>.
On 12/19/07, Matthieu Riou <ma...@offthelip.org> wrote:
>
> 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.


If you meant for it to exist, it would be there.  If you didn't mean for it
to exist, then I would expect it to fail.  The idea of data created
magically is too much black magic for me.

Assaf


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
>



-- 
CTO, Intalio
http://www.intalio.com