I think these problems come down to what a transformation should be doing. All transformations are taking information in one form, and creating an alternative representation of that information in another form.
keyword is representation - another form is based on metamodel. And transformations should represent one metamodel entities into anothers.
Specifically a PIM to PSM transform is all about adding detail that has been abstracted out of the PIM.
I suggest that your simple transformation above is not trying to do that. Instead it is trying to add new information. Where did that information come from? How does EA (or your transformation) know that ClassA and ClassB are related?
New information adding also can be part of transformation, as it represents new details (before transformation this new information wasn't necessary). New information comes from metamodel and transformation knows that (as I know). Abstraction doesn't mean, that all information should be already in PIM - that wouldn't be PIM, there I pay attention to things, which are important at the PIM level.
PIM can't know, that ClassA and ClassB are related - it's a transformation duty to know such details. And my transformation knows, that ClassA and ClassB are related.
In this case it can only be coming from knowing exactly what the input to your transformation will be, and it knows how to handle that specific input. What happens if someone uses your transformation on ClassC, ClassD and ClassE?
that's why package template calls dependency template; whole models are transformed in MDA - of course, there could be models of single class - transformations will know how to deal with it following metamodel and transformation rules
No, the classes don't need to exist before the transformation. But the classes they are created from do need to be.
... but if PIM doesn't need such classes, then I'm forced to create them (even they don't belong to abstraction level) in order to use EA transformation capability. Transformation drives PIM...
Names wouldn't work at all. What happens if someone changes the name of a PIM class. Then the link is broken. GUIDs never change. 1
I have created references to classes with names, which match UML class name and I'm responsible to endure UML class names uniqueness. It's easier to remember reference not by GUID, but by reference's name (match UML class name in my case)
Something like this:
%TRANSFORM_REFERENCE_EX(className)%
Transformation language (declarative-imperative) must be flexible and support all kind transformations ;-)
This comes from the above that we don't add information that comes from nowhere.
it comes from mind inspirations ;-) or metamodels ;-)
If there isn't a relation between the classes in the PIM, then there shouldn't be a relation in the PSM. If there needs to be a relation between the PSM classes, there needs to be a relation between the PIM classes. 2
This is the quote of truth (in EA context). But what, if relation between PIM classes is redundant in PIM (but not in PSM) abstraction level.
Small example of PIM-to-PIM refinement:
source PIM: 2 classes - man, dog; association between man and dog
target PIM: man and dog are related with place, so there should be 3 classes: man, dog, place; association between man and dog and man-place, dog-place dependencies.
Similar example:
PIM:

PSM:

And if a source model is large and complicated, then current state of the transformation language can't help at all