Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsResource.save output is invalid XMI file
https://www.eclipse.org/forums/index.php/mv/msg/452382/1006462/#msg_1006462
I'm using org.eclipse.emf.ecore.resource.Resource.save(OutputStream outputStream, Map<?, ?> options) to seliaze XMI resource
When opening the output file, I'm getting Unresolved Reference Exception
org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference '//@elements.13'. (platform:/resource/my.generator.project.TestAllWithnewModel/src/metamodel/t.xmi, 7, 138)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardReferences(XMLHandler.java:1154)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHandler.java:1228)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:737) for the elements from 9 to 14 (Which are the last elements of the file). Evernthough they are present in the file.
The main difference between the output of save method and the original XMI scheme is that the original scheme uses structured elements when referring to a list while save method doesn't.
Any information about how to solve this problem? Another question please how can I add the schema location to the output file before calling save function?
I provided the original working XMI file, the output file (I highlighted the difference in red here) and the code I'm using.
Thanks for your help.
Houssam
The code to call the serializer
Resource xmiresource = resSet.createResource(URI.createURI("test.xmi"));
xmiresource.getContents().add(model);
xmiresource.save(xmi, Collections.EMPTY_MAP);
On 31/01/2013 3:23 PM, Houssam Abdoullah wrote:
> Hello all,
> I'm using org.eclipse.emf.ecore.resource.Resource.save(OutputStream outputStream, Map<?, ?> options) to seliaze XMI resource
> When opening the output file, I'm getting Unresolved Reference Exception
> org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference '//@elements.13'. (platform:/resource/my.generator.project.TestAllWithnewModel/src/metamodel/t.xmi, 7, 138)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardReferences(XMLHandler.java:1154)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHandler.java:1228)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:737)
> for the elements from 9 to 14 (Which are the last elements of the file). Evernthough they are present in the file.
> The main difference between the output of save method and the original XMI scheme is that the original scheme uses structured elements when referring to a list while save method doesn't.
> Any information about how to solve this problem? Another question please how can I add the schema location to the output file before calling save function?