Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Handling of backslash
Handling of backslash [message #1848969] Mon, 27 December 2021 09:29 Go to next message
Eclipse UserFriend
Dear all,

I am working on an Xtext project whose target/instance model is an XML document. When creating a model (XML document), it needs to accept a string including backslash (\), and this backslash is not an escape character. For instance, the XML document may contain something like below.
...
<script>
abc\def
</script>
...

Is it possible to define an Xtext grammar that supports above?

I would appreciate any advice.

Thank you very much in advance.
Re: Handling of backslash [message #1848973 is a reply to message #1848969] Mon, 27 December 2021 12:42 Go to previous message
Eclipse UserFriend
Hi

Yes.

If you don;'t like the half-built-in STRING token typically imposed by Terminal.xtext, redefine it or define a different token.

Make sure you define a suitable replacement for e.g. DoubleQuotedStringConverter that doesn't interpret backslash, but probably does support &gt; etc. You may find suitable encode/decode utility routines perhaps in the EMF XML support, perhaps in the SAX parser.

Regards

Ed Willink
Previous Topic:Defined 2-way link-list xtext grammar issues
Next Topic:Log4j 1.x updates to Log4j2
Goto Forum:
  


Current Time: Mon May 19 17:23:49 EDT 2025

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

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

Back to the top