[ATL] Help with Query and OCL [message #665740] |
Fri, 15 April 2011 16:51 |
Thanasis Naskos Messages: 22 Registered: March 2011 |
Junior Member |
|
|
Hi,
I have an XML file holding parameters, called "parameters.xml":
<parameters>
<param name="prototypePackage" value="ConcretePackage"/>
<param name="prototypeClass" value="ConcreteClass1"/>
<param name="prototypeClass" value="ConcreteClass2"/>
...
<param name="prototypeClass" value="ConcreteClassN"/>
</parameters>
I want to make a Query that gets the parameters and produces a file containing the above text:
This is a list with parameters
This is a Class parameter: ConcreteClass1;
This is a Class parameter: ConcreteClass2;
...
This is a Class parameter: ConcreteClassN;
End of parameters list
I figure out how to get the parameters from the XML but i can't find how to use iteration to produce the text above.
This is the code I have written so far:
query prototypeManager = ('This is a list with parameters'+
for (c in getConcreteClasses()) {
'This is a Class parameter: '+c.getAttrVal('value')+';'
}
+'End of parameters list').writeTo('prototypeTransformation/PrototypeManager.txt');
uses XMLHelpers;
helper def : getConcreteClasses() : Sequence(String) =
XML!Element.allInstances()->select(e |
e.name = 'param'
)->select(e |
e.getAttrVal('name') = 'prototypeClass');
I'm getting the following error in "for" expression:
no viable alternative at input 'for'
mismatched input '{' expecting SEMI
I'm not used to the ATL and OCL so any help would be appreciated!!
[Updated on: Fri, 15 April 2011 16:55] Report message to a moderator
|
|
|
|
|
|
Re: [ATL] Help with Query and OCL [message #682319 is a reply to message #665740] |
Fri, 10 June 2011 20:33 |
No real name Messages: 1 Registered: June 2011 |
Junior Member |
|
|
Hello,
I have a smiliar problem like Thanasis. Unfortunatelly I am not able to solve it.
This is my XML File (shortened):
<?xml version="1.0" encoding="ISO-8859-1"?>
<MYFILE xmi:version="2.0" xmlns:xmi="http:..." xmlns:xsi="..." xmlns="...">
<root>
<incl name="MainItem">
<incl name="Item1">
</incl>
<inclname="Item2">
</incl>
<incl name="Item">
</incl>
</incl>
</root>
</MYFILE>
And this is what I want to produce:
<?xml version="1.0" encoding="UTF-8"?>
<MainItem>
<item1>
</Item1>
<item2>
</Item2>
<item3>
</Item3>
</MainItem>
Tried so start like Thanasis for the MainItem, but output is just "This is a list with parameters"..
query now = thisModule.getConcreteClasses()->iterate(c; res : String = 'This is a list with parameters' | res + '\nThis is a Class parameter: '+c.getAttrVal('name')+';'+'\nEnd of parameters list').writeTo('fu.txt');
helper def : getConcreteClasses() : Sequence(String) =
XML!Element.allInstances()->select(e |e.name = 'incl')->select(e |e.getAttrVal('name') = 'MainItem');
Sitting here since hours for a couple of transformations - Cannot find a solution to this one. Anybody can help?
[Updated on: Fri, 10 June 2011 20:49] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03297 seconds