[ATL] How to iterate elements to find the value, corresponding to a certain name? [message #557322] |
Mon, 06 September 2010 16:49 |
Alexey Messages: 61 Registered: January 2010 |
Member |
|
|
Hello!
In my transformation I need to get the value of the attribute "version" (which is =1):
rule DocumentRootElement {
from
s : XML!Root (s.name = 'History')
to
t : Garmin!DocumentRoot(
....... some other transformations...... )
,
t2 : Garmin!HistoryType
(
version <-s.getValue('Version')
)
The helper "getValue()" looks like that:
helper context XML!Element def: getValue(name : String) : String=
let a: Sequence(XML!Element) = self->select(c | c.name = name) in
if a.isEmpty() then 'no_value'
else
a.first().children->first().value
endif;
The part of the source-model, where the iteration has to be done (so, in other words, where the value for the name='version' has to be found) is here:
<Root xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="XML" startLine="1"
startColumn="1" endLine="21489" endColumn="11" name="History">
<children xsi:type="Attribute" name="xmlns" value="http://www.garmin.com/xmlschemas/ForerunnerLogbook"/>
<children xsi:type="Attribute" name="xmlns:xsi" value="http://www.w3.org/2001/XMLSchema-instance"/>
<children xsi:type="Attribute" name="xsi:schemaLocation" value="http://www.garmin.com/xmlschemas/ForerunnerLogbook http://www.garmin.com/xmlschemas/ForerunnerLogbookv1.xsd"/>
<children xsi:type="Attribute"[B] [COLOR=blue]name="version" value="1"[/COLOR][/B]/>
<children xsi:type="Text" startLine="3" startColumn="264" endLine="4" endColumn="6"
name="#text" value="
 "/>
<children xsi:type="Element" startLine="4" startColumn="6" endLine="1310" endColumn="11"
name="Run">
But it doesnt work!
ATL tells me this:
Quote: | org.eclipse.m2m.atl.engine.emfvm.VMException: Cannot iterate on IN!History
at getValue2#4(XML2Garmin.atl[295:33-295:64])
local variables: self=IN!History, name='Version'
|
What is wrong? Could someone please help me?
Thank you very much.
Alexey
[Updated on: Mon, 06 September 2010 17:19] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03970 seconds