Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to Serialize Strings with line breaks?
How to Serialize Strings with line breaks? [message #1819338] Mon, 13 January 2020 13:36 Go to next message
Lukas Schaus is currently offline Lukas SchausFriend
Messages: 35
Registered: October 2016
Member
Hello xtexters,

i am trying to serialize a model into a textfile which works quiet well. The only challange that I am facing is to serialize Strings that contain newlines:

consider the following grammar rule:
MyRule:
    'String' value=STRING


If i try to serialize a String like "I want to\nserialize multiline strings" somehow like that:
...
myElem.value =  "I want to\nserialize multiline strings"
myResource.save(null)


unfortunately the serialized text looks like this
String "I want to\nserialize multiline strings"


i would like to achieve this:
String "I want to
serialize multiline strings"


If someone has a hint i would be more than happy.

Thank you in advance

[Updated on: Mon, 13 January 2020 14:11]

Report message to a moderator

Re: How to Serialize Strings with line breaks? [message #1819349 is a reply to message #1819338] Mon, 13 January 2020 16:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13643
Registered: July 2009
Senior Member
did you check the value converters for your STRING terminal?

besides

see https://stackoverflow.com/questions/50904789/formatting-string-content-xtext-2-14/50912579#50912579


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to Serialize Strings with line breaks? [message #1819381 is a reply to message #1819349] Tue, 14 January 2020 08:45 Go to previous message
Lukas Schaus is currently offline Lukas SchausFriend
Messages: 35
Registered: October 2016
Member
Hello Christian,

thank you for your suggestions.

Quote:

did you check the value converters for your STRING terminal?


Now I did ;). It is the standard String value converter. But i will check it in a new project just to be sure.

Quote:

besides

see https://stackoverflow.com/questions/50904789/formatting-string-content-xtext-2-14/50912579#50912579


I was thinking about that before, but it is quiet drastic to replace all \n in strings with newlines. Maybe I should then use some special chars that are very unlikely to be written by users.

Can I use a different Formatter for serialization than the one that the is called bei ctrl+shift+f ?
Previous Topic:Error in 15 Minute Tutorial Extended?
Next Topic:Search for reference models in project's Maven classpath
Goto Forum:
  


Current Time: Fri Oct 30 01:58:39 GMT 2020

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

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

Back to the top