diff --git a/pyecore/resources/resource.py b/pyecore/resources/resource.py
index <HASH>..<HASH> 100644
--- a/pyecore/resources/resource.py
+++ b/pyecore/resources/resource.py
@@ -206,7 +206,7 @@ class Resource(object):
         # sets an uuid if the resource should deal with
         # and obj has none yet (addition to the resource for example)
         if not obj._xmiid:
-            uuid = uuid4()
+            uuid = str(uuid4())
             self.uuid_dict[uuid] = obj
             obj._xmiid = uuid
 
diff --git a/pyecore/resources/xmi.py b/pyecore/resources/xmi.py
index <HASH>..<HASH> 100644
--- a/pyecore/resources/xmi.py
+++ b/pyecore/resources/xmi.py
@@ -272,7 +272,7 @@ class XMIResource(Resource):
         if self._use_uuid:
             self._assign_uuid(obj)
             xmi_id = '{{{0}}}id'.format(xmi_url)
-            node.attrib[xmi_id] = self._xmiid
+            node.attrib[xmi_id] = obj._xmiid
 
         # feats = obj._isset if obj._isset else eclass.eAllStructuralFeatures()
         for feat in obj._isset:
Fix XMI serialization when uuids are used