Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Resolving element references after injection
Resolving element references after injection [message #21393] Wed, 13 August 2008 12:26 Go to next message
Eclipse UserFriend
Originally posted by: mozafara.cs.man.ac.uk

Hi,
I am working on a project where I use TCS to transform textual syntax of
a DSL into a model, then the model is transformed into c++ code using
JET2 templates. JET loads the injected xmi file from TCS output and the
final code is generated by appropriate XPath queries embedded in jet
templates.
I have an issue with the way TCS serializes non-container references.
For example, take notice how the following km3 snippet is represented in
the model.

class Terminator {
reference nextstate : State;
}

the corresponding TCS template is:

template Terminator :
"nextstate" reference{refersTo=name}
;

after injection we get:
<terminator location="7:2-7:21" nextstate="//@process/@state.0"/>

the value of "nextstate" attribute is a reference to the the instance of
a "state" class in the serialized tree.
The big issue is that the expression is not XPath compatible and I have
to resort to ugly hacks to convert it into a valid path expression. The
XPath equivalent of the above example would be "//process/state[1]".

Is there a way to produce XPath friendly path references from TCS
injections? What does the current format stand for?
Re: Resolving element references after injection [message #21916 is a reply to message #21393] Tue, 14 October 2008 10:54 Go to previous message
Eclipse UserFriend
Hi Amin,

Actually, TCS is not responsible for the XMI serialization: EMF is.

I remember reading about a similar problem and corresponding solutions
(probably on the EMF newsgroup), but I cannot find where right now. You
may want to ask this question on the EMF newsgroup.

Note that you may also ask EMF to use xmi:ids, which is generally much
simpler than XPath (or XPath-like) expressions.


Regards,

Frédéric

Amin Mozafari a écrit :
> Hi,
> I am working on a project where I use TCS to transform textual syntax of
> a DSL into a model, then the model is transformed into c++ code using
> JET2 templates. JET loads the injected xmi file from TCS output and the
> final code is generated by appropriate XPath queries embedded in jet
> templates.
> I have an issue with the way TCS serializes non-container references.
> For example, take notice how the following km3 snippet is represented in
> the model.
>
> class Terminator {
> reference nextstate : State;
> }
>
> the corresponding TCS template is:
>
> template Terminator :
> "nextstate" reference{refersTo=name}
> ;
>
> after injection we get:
> <terminator location="7:2-7:21" nextstate="//@process/@state.0"/>
>
> the value of "nextstate" attribute is a reference to the the instance of
> a "state" class in the serialized tree.
> The big issue is that the expression is not XPath compatible and I have
> to resort to ugly hacks to convert it into a valid path expression. The
> XPath equivalent of the above example would be "//process/state[1]".
>
> Is there a way to produce XPath friendly path references from TCS
> injections? What does the current format stand for?
Previous Topic:[TCS] registering PDL extensions
Next Topic:[Announce] TMF XTEXT 0.7.0 I200810290511 is available
Goto Forum:
  


Current Time: Tue Jul 22 12:06:18 EDT 2025

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

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

Back to the top