Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] XML2BPEL
[ATL] XML2BPEL [message #44638] Tue, 05 June 2007 19:48 Go to next message
Eclipse UserFriend
Originally posted by: rb_account.yahoo.de

Hello,

I could need some basic hints for translating a xml-model to a bpel-mode=
l.
Both metamodels are from am3-zoo. The input-model is already transformed=
=

to ecore format.

input-model:
---------------------------------------------------------
<?xml version=3D"1.0" encoding=3D"ISO-8859-1"?>
<Root xmi:version=3D"2.0" xmlns:xmi=3D"http://www.omg.org/XMI" =

xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" xmlns=3D"XML" =

startLine=3D"9" startColumn=3D"11" endLine=3D"73" endColumn=3D"11" name=3D=
"process">
<children xsi:type=3D"Attribute" name=3D"name" value=3D"ExampleProces=
s"/>
<children xsi:type=3D"Attribute" name=3D"targetNamespace" =

value=3D"de.unibamberg.wiai.seda"/>
<children xsi:type=3D"Attribute" name=3D"suppressJoinFailure" value=3D=
"yes"/>
<children xsi:type=3D"Attribute" name=3D"xmlns:tns" =

value=3D"de.unibamberg.wiai.seda"/>
<children xsi:type=3D"Attribute" name=3D"xmlns" =

value=3D"http://schemas.xmlsoap.org/ws/2004/03/business-process/"/>
<children xsi:type=3D"Element" startLine=3D"18" startColumn=3D"19" =

endLine=3D"29" endColumn=3D"20" name=3D"partnerLinks">
<children xsi:type=3D"Element" startLine=3D"28" startColumn=3D"24" =
=

endLine=3D"28" endColumn=3D"24" name=3D"partnerLink">
<children xsi:type=3D"Attribute" name=3D"name" value=3D"client"/>=

<children xsi:type=3D"Attribute" name=3D"partnerLinkType" =

value=3D"tns:ExampleProcess"/>
<children xsi:type=3D"Attribute" name=3D"myRole" =

value=3D"ExampleProcessProvider"/>
<children xsi:type=3D"Attribute" name=3D"partnerRole" =

value=3D"ExampleProcessRequester"/>
</children>
</children>
.....


My first try to transform the model looks like this:
------------------------------------------------------------
module XML2BPEL; -- Module Template
create bpel : BPEL from xml : XML;

rule Root2Process {
from
r : XML!Root
to
p : BPEL!Process (
name <- r.children->select(a | a.name =3D 'name' and a.oclType() =3D=
=

XML!Attribute).first().value,
targetNamespace <- r.children->select(a | a.name =3D 'targetNamespac=
e' =

and a.oclType() =3D XML!Attribute).first().value
)
}
------------------------------------------------------------ -----
This works fine until now.

My questions concerning the transformation:
1a. Is this the correct way to do the transformation: selecting the =

attribute with the matching name and then retrieving its value?
1b. If the transformation is ok: Is there a possibility to write a =

helper-method that gets the two parameters "name" and "oclType" and =

returns the value...? What does it look like?
2. How do I proceed, e.g. how do I transform the partnerLink-Elements of=
=

the input-model to the bpel-model?
partnerLinks <- ....

I just need to get into the language. The beginning is quite difficult b=
ut =

I'm optimistic ;-)
So thanks for any help.

Best regards

Rainer Bernhard
Re: [ATL] XML2BPEL [message #44700 is a reply to message #44638] Wed, 06 June 2007 08:13 Go to previous message
Ã?ric Vépa is currently offline Ã?ric VépaFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Rainer,

Rainer Bernhard wrote:
> Hello,
>
> I could need some basic hints for translating a xml-model to a bpel-model.
> Both metamodels are from am3-zoo. The input-model is already transformed
> to ecore format.
>
> input-model:
> ---------------------------------------------------------
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Root xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="XML"
> startLine="9" startColumn="11" endLine="73" endColumn="11" name="process">
> <children xsi:type="Attribute" name="name" value="ExampleProcess"/>
> <children xsi:type="Attribute" name="targetNamespace"
> value="de.unibamberg.wiai.seda"/>
> <children xsi:type="Attribute" name="suppressJoinFailure" value="yes"/>
> <children xsi:type="Attribute" name="xmlns:tns"
> value="de.unibamberg.wiai.seda"/>
> <children xsi:type="Attribute" name="xmlns"
> value="http://schemas.xmlsoap.org/ws/2004/03/business-process/"/>
> <children xsi:type="Element" startLine="18" startColumn="19"
> endLine="29" endColumn="20" name="partnerLinks">
> <children xsi:type="Element" startLine="28" startColumn="24"
> endLine="28" endColumn="24" name="partnerLink">
> <children xsi:type="Attribute" name="name" value="client"/>
> <children xsi:type="Attribute" name="partnerLinkType"
> value="tns:ExampleProcess"/>
> <children xsi:type="Attribute" name="myRole"
> value="ExampleProcessProvider"/>
> <children xsi:type="Attribute" name="partnerRole"
> value="ExampleProcessRequester"/>
> </children>
> </children>
> ....
>
>
> My first try to transform the model looks like this:
> ------------------------------------------------------------
> module XML2BPEL; -- Module Template
> create bpel : BPEL from xml : XML;
>
> rule Root2Process {
> from
> r : XML!Root
> to
> p : BPEL!Process (
> name <- r.children->select(a | a.name = 'name' and
> a.oclType() = XML!Attribute).first().value,
> targetNamespace <- r.children->select(a | a.name =
> 'targetNamespace' and a.oclType() = XML!Attribute).first().value
> )
> }
> ------------------------------------------------------------ -----
> This works fine until now.
>
> My questions concerning the transformation:
> 1a. Is this the correct way to do the transformation: selecting the
> attribute with the matching name and then retrieving its value?

Yes, it is the way to inject your sample into your real input model
(BPEL in your case).

> 1b. If the transformation is ok: Is there a possibility to write a
> helper-method that gets the two parameters "name" and "oclType" and
> returns the value...? What does it look like?

You can found many samples of common helpers on XML in the Zoo of
Transformations.

For example, two helpers often used:

--@begin helper getChildren
--@comments Returns all the children which type and name are given.
helper context XML!Element
def : getChildren(type : OclType, name : String) : Sequence(XML!Node) =
self.children->select(e|e.oclIsKindOf(type))->select(e|e.name = name);
--@end helper getChildren

--@begin helper getAttrVal
--@comments Returns the value of the first attribute which name is given.
helper context XML!Element
def : getAttrVal(name : String) : String =
let children : Sequence(XML!Attribute) =
self.getChildren(XML!Attribute,name) in
if children->notEmpty()
then children->first().value
else OclUndefined -- You also can return '' as a default value.
endif;
--@end helper getAttrVal

> 2. How do I proceed, e.g. how do I transform the partnerLink-Elements of
> the input-model to the bpel-model?
> partnerLinks <- ....
You have to create a rule for each element of your BPEL metamodel, you
consider. For example (the name is only for example purpose, I don't
know BPEL metamodel):

rule Element2PartenerLink {
from
e : XML!Element (
e.name = 'partnerLinks'
)
to
b : BPEL!...
}

The elements will be created but not linked. For doing that, you can
reuse the helper getChildren in the rule Root2Process.

For example:
rule Root2Process {
from
r : XML!Root
to
p : BPEL!Process (
...,
partnerLinks <- r.getChildren(XML!Element,'partnerLinks')
)
}

The link will be done automatically.

>
> I just need to get into the language. The beginning is quite difficult
> but I'm optimistic ;-)
> So thanks for any help.
>
> Best regards
>
> Rainer Bernhard


--
Éric Vépa

SODIUS
6, rue de la Cornouaille - BP 91941
44319 Nantes, France
Email: evepa@sodius.com

www.mdworkbench.com
Draw more value from your models
Previous Topic:Enumeration problem
Next Topic:[ATL] New ATL use case: Using a UML modeler to generate metamodels
Goto Forum:
  


Current Time: Tue Sep 24 02:02:16 GMT 2024

Powered by FUDForum. Page generated in 0.04247 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top