Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » transforming an XML to text file
transforming an XML to text file [message #1066695] Wed, 03 July 2013 15:26 Go to next message
achraf lyazidi is currently offline achraf lyazidi
Messages: 10
Registered: May 2013
Junior Member
Hi everyone,

im trying to transform and XML file to a textual one with ATL, but when i run my transformation, i got this error:

Quote:
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation toString2: wrong number of parameters
at toString2#86(XML2Text.atl[23:6-23:32])
local variables: self=IN!text, indent=' ', na=Sequence {IN!<unnamed>}, a=Sequence {}, acc='', e=IN!<unnamed>
at toString2#86(XML2Text.atl[23:6-23:32])
local variables: self=IN!name, indent=' ', na=Sequence {IN!text}, a=Sequence {}, acc='', e=IN!text
at toString2#86(XML2Text.atl[23:6-23:32])
local variables: self=IN!pnml, indent='', na=Sequence {IN!name, IN!net}, a=Sequence {IN!xmlns}, acc='', e=IN!name
at main#7(XML2Text.atl[1:18-3:25])
local variables: self=XML2Text : ASMModule



This is my ATL file :
query XML2Text = XML!Root.allInstances()
	->asSequence()
	->first().toString2('').writeTo('C:/Users/Desktop/Master/Semestre 4- PFE/workspacepfe/fam/Models/outProblemOrAndText.xml');

helper context XML!Element def: toString2(indent : String) : String =
	let na : Sequence(XML!Node) =
		self.children->select(e | not e.oclIsKindOf(XML!Attribute)) in
	let a : Sequence(XML!Node) =
		self.children->select(e | e.oclIsKindOf(XML!Attribute)) in
	indent + '<' + self.name + 
	a->iterate(e; acc : String = '' |
		acc + ' ' + e.toString2()
	) +
	if na->size() > 0 then
		'>'
		+ na->iterate(e; acc : String = '' |
			acc + 
			if e.oclIsKindOf(XML!Text) then
				''
			else
				'\r\n'
			endif
			+ e.toString2(indent + '  ')
		) +
		if na->first().oclIsKindOf(XML!Text) then
			'</' + self.name + '>'
			else
				'\r\n' + indent + '</' + self.name + '>'
		endif
	else
		'/>'
	endif;

helper context XML!Attribute def: toString2() : String =
	self.name + '=\"' + self.value + '\"';

helper context XML!Text def: toString2() : String =
	self.value;



Note that before i got this XML file, i did 2 transformation from BPMN to PetriNet, and from PetriNet to XML
Re: transforming an XML to text file [message #1066743 is a reply to message #1066695] Thu, 04 July 2013 04:03 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
line 23 you're potentially calling toString2 on a XML!Text but with a parameter, but the toString2 on XML!Text takes no parameter.
Previous Topic:Problem with ATL compiling
Next Topic:Full name reference - Classifiers seem not to be equal
Goto Forum:
  


Current Time: Fri Jul 25 12:08:03 EDT 2014

Powered by FUDForum. Page generated in 0.01716 seconds