Helper returns a sequence or set [message #699779] |
Fri, 22 July 2011 09:45 |
Fy Za Messages: 245 Registered: March 2010 |
Senior Member |
|
|
I define an helper that returns a Sequence a an element: helper ............... : Sequence(MM!FiacreProcessName),
but the problem that is not is the best form, so the returned form is like this :
<port="//@declarations.1/@transition.7/@processID.0/@fiacre_process_name //@declarations.1/@transition.7/@processID.1/@fiacre_process_name"/>
but I'd have the result like this
<port="//@declarations.1/@transition.7/@processID.0/@fiacre_process_name/>
<port="//@declarations.1/@transition.7/@processID.1/@fiacre_process_name"/>
this is the rule
rule FiacreLabelType2FiacreLabelType {
from
fiacre_label_type_ins : InstancieMetaModel!FiacreLabelType(fiacre_label_type_ins.oclIsTypeOf(InstancieMetaModel!FiacreLabelType))
to
fiacre_label_type_lie : LieMetaModel!FiacreLabelType(
name <- fiacre_label_type_ins.name,
ports <- thisModule.getPort(fiacre_label_type_ins.name)
)
}
ports is a reference 0..*
and this is the helper
helper def : getPort(labelName : String) : Set(InstancieMetaModel!FiacreProcessName) =
let alltransitions : Sequence(InstancieMetaModel!Transition) =
InstancieMetaModel!Transition.allInstances().asSequence() in
alltransitions->iterate(t; y : InstancieMetaModel!Transition = alltransitions->first() |
if t.label.name = labelName
then
t
else
y
endif
).processID->collect(e|e.fiacre_process_name)
;
please help me
thanks
[Updated on: Fri, 22 July 2011 09:50] Report message to a moderator
|
|
|
Re: Helper returns a sequence or set [message #699883 is a reply to message #699779] |
Fri, 22 July 2011 14:25 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
What you show doesn't even look like well formed XML. With extended
meta data annotations in your model, you can direct a feature to be
serialized as an element rather than an attribute.
On 22/07/2011 2:45 AM, ZALILA Faiez wrote:
> I define an helper that returns a Sequence a an element: helper
> ............... : Sequence(MM!FiacreProcessName),
>
> but the problem that is not is the best form, so the returned form is
> like this :
>
> <port="//@declarations.1/@transition.7/@processID.0/@fiacre_process_name
> //@declarations.1/@transition.7/@processID.1/@fiacre_process_name"/>
>
> but I'd have the result like this
> <port="//@declarations.1/@transition.7/@processID.0/@fiacre_process_name/>
>
> <port="//@declarations.1/@transition.7/@processID.1/@fiacre_process_name"/>
>
>
> please help me
> thanks
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02983 seconds