General (#1) - trace-bound vs. key-bound (#35) - Message List

trace-bound vs. key-bound
 unsolved

hey y'all,

my understanding of the key concept is that it states an identifying property. now here is an excerpt from a transformation that uses key:

key EDataType {name};
top relation dataTypes {
  inP, outP : EPackage;
  icn, n : String;
  checkonly domain source enum : EDataType {
    ePackage = inP,
    instanceClassName = icn,
    name = n
  };
  enforce domain target enum : EDataType {
    ePackage = outP,
    instanceClassName = icn,
    name = n
  };
  when {
    package2Package(inP, outP);
  }
}

when i input a model that has multiple instances of EDataType with the same name (e.g. "EString") i expected them to be "collapsed" to one in the target. but there is only a warning

WARNING: Trace-bound value differs from key-bound value or WARNING: Last key found 2 matching instances!

and all instances carried over to the target. where is my mistake? does the key apply to the source model, too?

---cheers Martin

  • Message #101

    does the key apply to the source model, too?

    No, only to the models associated to the target direction.

    So it can only be that in the target model, there already exists two instances with the same name and then, the engine not knows which to use.

    May I know what you try to do? Last week, I helped someone trying to create an EDataType with name EString in the target model.

Attachments

No attachments created.