Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Helper returns a sequence or set
Helper returns a sequence or set [message #699779] Fri, 22 July 2011 05:45 Go to next message
Fi Fi is currently offline Fi Fi
Messages: 133
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 05: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 10:25 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25740
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
Previous Topic:[ATL] Using own model implementation instances instead of DynamicEObjImpl as in/output
Next Topic:[QVTo] Debugging in a second eclipse instance
Goto Forum:
  


Current Time: Thu Apr 17 05:51:27 EDT 2014

Powered by FUDForum. Page generated in 0.01843 seconds