[TCS] indexing values in list property [message #5323] |
Fri, 14 March 2008 05:51  |
Eclipse User |
|
|
|
Hi,
Assuming I had a Metamodel class like this in KM3:
class MyClass {
attribute name : String;
attribute something : String;
reference elements[2-2] ordered container : Element
}
class Element {
attribute name : String;
}
is there any way I could refer to the first or the second of elements in
my TCS template directly?
Such as something like this (I invented "index" here):
template MyClass
: name ","
elements{index=0, referTo=name} ":"
something ","
elements{index=1, referTo=name}
;
|
|
|
Re: [TCS] indexing values in list property [message #7320 is a reply to message #5323] |
Fri, 14 March 2008 06:38   |
Eclipse User |
|
|
|
Hello,
Did you try something like:
template MyClass
: name "," elements{index=0, referTo=name, separator =
":" something ","}
;
?
Regards,
Frédéric Jouault
Thibault a écrit :
> Hi,
>
> Assuming I had a Metamodel class like this in KM3:
>
> class MyClass {
> attribute name : String;
> attribute something : String;
> reference elements[2-2] ordered container : Element
> }
> class Element {
> attribute name : String;
> }
>
>
> is there any way I could refer to the first or the second of elements in
> my TCS template directly?
>
> Such as something like this (I invented "index" here):
>
> template MyClass
> : name "," elements{index=0, referTo=name} ":"
> something ","
> elements{index=1, referTo=name}
> ;
>
>
>
|
|
|
Re: [TCS] indexing values in list property [message #7341 is a reply to message #7320] |
Fri, 14 March 2008 07:37  |
Eclipse User |
|
|
|
Hi,
> template MyClass
> : name "," elements{index=0, referTo=name, separator =
> ":" something ","}
> ;
I assume you mean (leaving out the imaginary "index=0"):
template MyClass
: name "," elements{referTo=name, separator =
":" something ","}
;
I did not try, though I thought about using the separator in a similar
case.
But in a way, that's cheating to me, meaning somebody would have to think
about it to understand that the result would be "firstelement : something,
otherelement"
And this solution would not work for 3 elements and some similar problem.
I guess from your suggestion that TCS currently does not generally allow
referring to indexes of elements in property lists, though in the case of
2 elements, the separator concept might be used as workaround.
In any case thank you, as I had not thought the separator to be so
flexible to allow nesting properties in it.
|
|
|
Powered by
FUDForum. Page generated in 0.03485 seconds