[ATL] ATL transformation output [message #648566] |
Thu, 13 January 2011 14:40 |
Dave Messages: 37 Registered: September 2010 |
Member |
|
|
Hi all,
I would like to ask you a few things about ATL. I'm doing a trasformation and I have some puzzles to solve:
1) In output I get an xml file whose structure is like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<spmif:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spmif="spmif">
<project projectName="RequestPatientInfoPages">
..................
</project>
</spmif:DocumentRoot>
while I would like to have no tags DocumentRoot. The ATL-rule that generates the whole output (ie the first is executed) is:
rule Project {
from
i : UML2!UseCase (i.name = thisModule.defaultUseCase)
to
o : spmif!DocumentRoot (
)
do {
o.project <- thisModule.Scenarios(i);
o;
}
}
where thisModule.defaultUseCase is the name of an UML <UseCase> and is the call to a rule that generates the elements within the project element.
Do you know how to avoid the insertion of the DocumentRoot tag?
2) Consider the following XSD fragment from which the target metamodel derives:
<xs:element name="Node" type="spmif:Node_type"/>
<xs:element name="ProcessingNode" type="spmif:ProcessingNode_type" substitutionGroup="spmif:Node"/>
<xs:element name="BasicNode" type="spmif:BasicNode_type" substitutionGroup="spmif:Node"/>
<xs:element name="LinkNode" type="spmif:LinkNode_type" substitutionGroup="spmif:ProcessingNode"/>
<xs:element name="SynchronizationNode" type="spmif:SynchronizationNode_type" substitutionGroup="spmif:ProcessingNode"/>
<xs:element name="ExpandedNode" type="spmif:ExpandedNode_type" substitutionGroup="spmif:ProcessingNode"/>
<xs:element name="CompoundNode" type="spmif:CompoundNode_type" substitutionGroup="spmif:Node"/>
<xs:element name="RepetitionNode" type="spmif:RepetitionNode_type" substitutionGroup="spmif:CompoundNode"/>
<xs:element name="SplitNode" type="spmif:SplitNode_type" substitutionGroup="spmif:CompoundNode"/>
<xs:element name="PardoNode" type="spmif:PardoNode_type" substitutionGroup="spmif:CompoundNode"/>
<xs:element name="CaseNode" type="spmif:CaseNode_type" substitutionGroup="spmif:CompoundNode"/>
<xs:complexType name="EG_type">
<xs:sequence>
<xs:element name="Node" type="spmif:Node_type" maxOccurs="unbounded"/>
<xs:element name="Arc" type="spmif:Arc_type" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="EGname" type="xs:string" use="required"/>
<xs:attribute name="EGId" type="xs:ID" use="required"/>
<xs:attribute name="StartNode" type="xs:IDREF" use="required" ecore:reference="spmif:Node_type"/>
<xs:attribute name="ModificationDateTime" type="xs:dateTime" use="optional"/>
<xs:attribute name="SWmodelname" type="xs:string" use="optional"/>
<xs:attribute name="SWdescription" type="xs:string" use="optional"/>
<xs:attribute name="Deadline" type="spmif:positivefloat" use="optional"/>
</xs:complexType>
As you can see, the complexType EG_type is composed of Node(s) and Arc(s). Node is the most generic and it is "extended" by several other types of elements.
The transformation obtains EG_type(s) that are structurally correct, but the output is not how I would like it was. In fact, each node is inserted as follows:
<node xsi:type="spmif:xxxNodeType" ATTRIBUTES>
.................
</node>
In practice, it inserts a node element, then it sets its type. Instead, I would like it was something like this:
This means I would like the tag on the node was already the name of its type, such as
Do you have any suggestion about this?
That's all, folks. I hope you can help me. If something is not clear, then let me know, so I'll explain it better.
Thank in advance for your time and consideration,
Dave.
|
|
|
|
Re: [ATL] ATL transformation output [message #648592 is a reply to message #648566] |
Thu, 13 January 2011 15:17 |
Vincent MAHE Messages: 129 Registered: July 2009 |
Senior Member |
|
|
Le 13/01/2011 15:40, Dave a écrit :
> Hi all,
>
> I would like to ask you a few things about ATL. I'm doing a
> trasformation and I have some puzzles to solve:
>
> 1) In output I get an xml file whose structure is like this:
>
As said Sylvain, the internal structure of the model file is for EMF
(and you manage your model through EMF tools, like ATL)
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <spmif:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spmif="spmif">
> <project projectName="RequestPatientInfoPages">
> ..................
> </project>
> </spmif:DocumentRoot>
>
> while I would like to have no tags DocumentRoot. The ATL-rule that
> generates the whole output (ie the first is executed) is:
>
So just generate projects:
> rule Project {
> from
> i : UML2!UseCase
> to
> p : spmif!Scenario (
> )
> }
>
.... and it is simpler :-)
>
> 2) Consider the following XSD fragment from which the target metamodel
> derives:
>
> <xs:element name="Node" type="spmif:Node_type"/>
> <xs:element name="ProcessingNode" type="spmif:ProcessingNode_type"
> substitutionGroup="spmif:Node"/>
> <xs:element name="BasicNode" type="spmif:BasicNode_type"
> substitutionGroup="spmif:Node"/>
> <xs:element name="LinkNode" type="spmif:LinkNode_type"
> substitutionGroup="spmif:ProcessingNode"/>
> <xs:element name="SynchronizationNode"
> type="spmif:SynchronizationNode_type"
> substitutionGroup="spmif:ProcessingNode"/>
> <xs:element name="ExpandedNode" type="spmif:ExpandedNode_type"
> substitutionGroup="spmif:ProcessingNode"/>
> <xs:element name="CompoundNode" type="spmif:CompoundNode_type"
> substitutionGroup="spmif:Node"/>
> <xs:element name="RepetitionNode" type="spmif:RepetitionNode_type"
> substitutionGroup="spmif:CompoundNode"/>
> <xs:element name="SplitNode" type="spmif:SplitNode_type"
> substitutionGroup="spmif:CompoundNode"/>
> <xs:element name="PardoNode" type="spmif:PardoNode_type"
> substitutionGroup="spmif:CompoundNode"/>
> <xs:element name="CaseNode" type="spmif:CaseNode_type"
> substitutionGroup="spmif:CompoundNode"/>
>
> <xs:complexType name="EG_type">
> <xs:sequence>
> <xs:element name="Node" type="spmif:Node_type" maxOccurs="unbounded"/>
> <xs:element name="Arc" type="spmif:Arc_type" minOccurs="0"
> maxOccurs="unbounded"/>
> </xs:sequence>
> <xs:attribute name="EGname" type="xs:string" use="required"/>
> <xs:attribute name="EGId" type="xs:ID" use="required"/>
> <xs:attribute name="StartNode" type="xs:IDREF" use="required"
> ecore:reference="spmif:Node_type"/>
> <xs:attribute name="ModificationDateTime" type="xs:dateTime"
> use="optional"/>
> <xs:attribute name="SWmodelname" type="xs:string" use="optional"/>
> <xs:attribute name="SWdescription" type="xs:string" use="optional"/>
> <xs:attribute name="Deadline" type="spmif:positivefloat" use="optional"/>
> </xs:complexType>
>
> As you can see, the complexType EG_type is composed of Node(s) and
> Arc(s). Node is the most generic and it is "extended" by several other
> types of elements.
> The transformation obtains EG_type(s) that are structurally correct, but
> the output is not how I would like it was. In fact, each node is
> inserted as follows:
>
> <node xsi:type="spmif:xxxNodeType" ATTRIBUTES>
> .................
> </node>
>
> In practice, it inserts a node element, then it sets its type. Instead,
> I would like it was something like this:
I suppose you have generated your metamodel from the XSD schema using
EMF genmodel for that. It is not a good tool because it only proposes a
flat metamodel with no containment heirarchy, which is a mess...
I had always rewrite my metamodels by hand (using Ecore diagram modeler)
and reading the DSL specifications.
>
> <xxxNode ATTRIBUTES/>
>
> This means I would like the tag on the node was already the name of its
> type, such as
>
> <BasicNode ATTRIBUTES/>
>
> Do you have any suggestion about this?
>
>
> That's all, folks. I hope you can help me. If something is not clear,
> then let me know, so I'll explain it better.
>
> Thank in advance for your time and consideration,
> Dave.
--
Cordialement
Vincent MAHÉ
Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
|
|
|
|
Re: [ATL] ATL transformation output [message #648642 is a reply to message #648592] |
Thu, 13 January 2011 18:36 |
Dave Messages: 37 Registered: September 2010 |
Member |
|
|
Hi Vincent,
thanks for your reply.
Quote: | > <?xml version="1.0" encoding="ISO-8859-1"?>
> <spmif:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spmif="spmif">
> <project projectName="RequestPatientInfoPages">
> ..................
> </project>
> </spmif:DocumentRoot>
>
> while I would like to have no tags DocumentRoot. The ATL-rule that
> generates the whole output (ie the first is executed) is:
>
So just generate projects:
> rule Project {
> from
> i : UML2!UseCase
> to
> p : spmif!Scenario (
> )
> }
>
.... and it is simpler
|
It's not so simple, because Scenario elements are generated by the rule Scenarios, that is called by the rule Project.
So, I would like to generate the Project element (tag in the xml resulting file) without generating DocumentRoot. As I said, Scenarios are correctly generated by the namesake rule.
Conceptually, from an UseCase a Project is generated; for this issue, what is inside Project is not important; what is really important, instead, is the DocumentRoot elimination. I think the problem is in the fact that Project is a child of DocumentRoot.
If I modify the generated meta-model (from the XML-Schema, as you guessed), I think I could resolve this issue and also the second one, but I would like to avoid an excessive modification of what has been generated.
Thanks a lot for your interesting,
Dave.
|
|
|
Powered by
FUDForum. Page generated in 0.03289 seconds