Resolving element references after injection [message #21393] |
Wed, 13 August 2008 12:26  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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?
|
|
|
Powered by
FUDForum. Page generated in 0.03253 seconds