XMI customization
Dear Vincent @aranega, Hope you and your family are all well! I stick with 0.9 and today, I bump it to 1.2. I have a customized implementation of Resource, where I'll do the following things:
def _go_across(self, obj, serialize_default=False):
self._cur_eobject = obj
return super()._go_across(obj, serialize_default)
def _build_path_from(self, obj):
if isinstance(obj, type):
obj = obj.eClass
if obj.eResource and obj.eResource != self and obj.eResource.uri:
return self._build_path_from_my_cross(obj) # this fun need obj, which I store with self._cur_eobject
return super()._build_path_from(obj)
# so, can we pass the
def _decode_ereferences(self):
for eobject, erefs in self._later:
for ref in erefs[:]:
if ref[1] in self.ref_to_be_ignored:
erefs.remove(ref)
super()._decode_ereferences()
def _decode_attribute(self, owner, key, value, node=None):
namespace, att_name = self.extract_namespace(key)
if att_name in self.attr_to_be_ignored:
return
if node:
return super()._decode_attribute(owner, key, value, node)
else:
return super()._decode_attribute(owner, key, value)
Would it be possible to provide some support for such customization, like:
- add attr_to_be_ignored to drop deprecated attribute when decode attribute
- add ref_to_be_ignored to drop ill-formed ref
- pass the obj of _go_across to _build_path_from This is just a soft suggestion. Thanks!
Hi @CFAndy!
Glad to see that the update was fine and that there is no regression for your project :) (I hope at least...).
Regarding the points you are suggesting, they are quite interesting as they really touch to model/metamodel evolution and could be helpful for others. Regarging them, I know EMF as a special option that you can pass during deserialization to explicitally ask to record the unknown features. This would take all unknow feature and store them in a special map in the resource so they can be accessed at another moment (option RECORD_UNKNOWN_FEATURE). Do you think this could cover your two first points?
For your last point, about passing the object from one method to the other, I think it could be done without so much trouble. I need to check.