problem with XML!Text [message #690951] |
Thu, 30 June 2011 13:08 |
Emwedish Endargachew Messages: 27 Registered: April 2011 |
Junior Member |
|
|
HI All,
I am working on XML2my model transformation. I had XML model and i used AM3 to get the XMI file from XML meta model and i am currently writing the transformation from XML to my model. The injection and stuff worked very well so as the rest of the transformation. However, something weird happened, i can not get the name which is my main part of the transformation. The name is an attribute in the target meta model where as in the source i find it Element which its value is represented in the Text child as it is shown in the part of my xml file written below:
--Example of source model
<children xsi:type="Element" startLine="10511" startColumn="5" endLine="10524" endColumn="20" name="Class1">
<children xsi:type="Attribute" name="id" value="SDVA"/>
<children xsi:type="Text" startLine="10511" startColumn="30" endLine="10512" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10512" startColumn="6" endLine="10512" endColumn="31" name="Name">
<children xsi:type="Text" startLine="10512" startColumn="11" endLine="10512" endColumn="26" name="#text" value="Simple Implementation"/>
</children>
<children xsi:type="Text" startLine="10512" startColumn="31" endLine="10513" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10513" startColumn="6" endLine="10513" endColumn="12" name="Info"/>
<children xsi:type="Text" startLine="10513" startColumn="12" endLine="10514" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10514" startColumn="6" endLine="10514" endColumn="27" name="DataSize">
<children xsi:type="Text" startLine="10514" startColumn="15" endLine="10514" endColumn="18" name="#text" value="0"/>
</children>
<children xsi:type="Text" startLine="10514" startColumn="27" endLine="10515" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10515" startColumn="6" endLine="10515" endColumn="35" name="DataType">
<children xsi:type="Text" startLine="10515" startColumn="15" endLine="10515" endColumn="26" name="#text" value="adtCustom"/>
</children>
<children xsi:type="Text" startLine="10515" startColumn="35" endLine="10516" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10516" startColumn="6" endLine="10516" endColumn="45" name="DataDimension">
<children xsi:type="Text" startLine="10516" startColumn="20" endLine="10516" endColumn="31" name="#text" value="Single"/>
</children>
<children xsi:type="Text" startLine="10516" startColumn="45" endLine="10517" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10517" startColumn="6" endLine="10517" endColumn="13" name="Range"/>
<children xsi:type="Text" startLine="10517" startColumn="13" endLine="10518" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10518" startColumn="6" endLine="10518" endColumn="14" name="Format"/>
<children xsi:type="Text" startLine="10518" startColumn="14" endLine="10519" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10519" startColumn="6" endLine="10521" endColumn="19" name="Description">
<children xsi:type="Text" startLine="10519" startColumn="18" endLine="10520" endColumn="7" name="#text" value="
					"/>
<children xsi:type="Element" startLine="10520" startColumn="7" endLine="10520" endColumn="14" name="Plain"/>
<children xsi:type="Text" startLine="10520" startColumn="14" endLine="10521" endColumn="7" name="#text" value="
				"/>
</children>
<children xsi:type="Text" startLine="10521" startColumn="19" endLine="10522" endColumn="6" name="#text" value="
				"/>
<children xsi:type="Element" startLine="10522" startColumn="6" endLine="10522" endColumn="39" name="IsRestricted">
<children xsi:type="Text" startLine="10522" startColumn="19" endLine="10522" endColumn="26" name="#text" value="False"/>
</children>
As you can see from the above file i have many attributes in target model which are elements in the source model. Now to explain it a little more, the above two in bold font are an example. I started working with them.
---------------------------HELPER
helper context XML!Element def: getSimpleStringDataValue() : String =
let eltC : Sequence(XML!Text) =
self.children->select(d | d.oclIsTypeOf(XML!Text))->asSequence()
in
if eltC->notEmpty()
then
eltC->first().value
else
''
endif;
-----------------Rule for the name
rule transform1
{
from input: XML!Element(input.name = 'Class1')
to output: TargetMM!Class1( name <- Sequence{i.getChildrenByName('nam')->collect(e | thisModule.resolveTemp(e, 'tps'))},
info <- Sequence{i.getChildrenByName('inf')->collect(e | thisModule.resolveTemp(e, 'tps'))},
............ )
}
rule Name{
from in:XML!Text(in.name = 'Name')
using {
textValues : String = inp.getSimpleStringDataValue();}
to nam:TargetMM!Name
(
name <- in.getOptIntAttrValue('Name')
)
)
}
This does not work correctly, and it is so annoying. After all i have done, i am stuck here
Please look at it and see what is my problem.
Thanks a lot
|
|
|
|
Powered by
FUDForum. Page generated in 0.02700 seconds