Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » XML2SQLtext
XML2SQLtext [message #1060554] Sun, 26 May 2013 18:07 Go to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
Hi,
I have a problem when i generate my ATL file is:

query XML2Text = XML!Root.allInstances()->asSequence().first().toString2('').writeTo('./projetSQL/example5.sql');

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
'insert into ' + self.name +' values('+
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()

)

else ''
endif;

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

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

and my result is like this:
insert into m values()
insert into composant values("F","01","6894f6ab",)
....

but I do not want it to take into consideration the root and leaves me something like this:

insert into composant values('F','01','6894f6ab')
....

I didn't found how to do the apostrophe.


thank you,

Samar

Re: XML2SQLtext [message #1060555 is a reply to message #1060554] Sun, 26 May 2013 18:55 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4186
Registered: July 2009
Senior Member
Hi

OCL 2.3 introduced the standard Java escape sequences (with the
exception of octal) so you could try \'.

However ATL uses a non-standard OCL vagely based on OCL 2.0, so it may
not support it; however most likely ATL like many other OCL
implementations anticipated the obvious specification evolution.

Regards

Ed Willink


On 26/05/2013 19:07, samar sousou wrote:
> Hi,
> I have a problem when i generate my ATL file is:
>
> query XML2Text =
> XML!Root.allInstances()->asSequence().first().toString2('').writeTo('./projetSQL/example5.sql');
>
> 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
> 'insert into ' + self.name +' values('+
> 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()
>
> )
> else ''
> endif;
>
> helper context XML!Attribute def: toString2() : String =
> self.value ;
>
> helper context XML!Text def: toString2() : String =
> self.value;
>
> and my result is like this:
> insert into m values()
> insert into composant values("F","01","6894f6ab",)
> ...
>
> but I do not want it to take into consideration the root and leaves me
> something like this:
>
> insert into composant values('F','01','6894f6ab')
> ...
>
> I didn't found how to do the apostrophe.
>
>
> thank you,
>
> Samar
>
>
Previous Topic:Create List in template
Next Topic:[Acceleo] Which Acceleo version do I need for UML 1.3
Goto Forum:
  


Current Time: Fri Dec 19 04:42:28 GMT 2014

Powered by FUDForum. Page generated in 0.04404 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software