What's a good way of serializing/deserializing models with embedded EPackage [message #894817] |
Tue, 10 July 2012 12:04  |
Eclipse User |
|
|
|
Hi all,
I have a use case where I would like to dynamically create an EPackage, create dynamic instances and then persist both within the same XML resource. I've done most of the work in the metamodel and editor and the resulting serialization file looks something like the one below. The EPackage is embedded in the publishedPackages feature and the EObject is in the feature "propertyValues" near the end. Ignore the strange "http-.." style url, that's becuase I couldn't post links.
When I try to open the file with the though I get an exception:
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'httpe://model.xxx.xxx.com/myapp/properties/1.0/scripts/1' not found.
....
What seems to be happening is that the refernece to embedded EPackage is not relative and attempt is made to resolve it. Of course this package is not registered anywhere so we get the exception. So I'm thinking I need to either register the embedded packages (in the ResourceSet?) as the resource is loaded or or need to make the reference to the ePackage from the EObject relative. I'm not really sure how to do either of these and overall not sure if the approach is correct to start with.
Does anyone know a good way to get this to work?
Thanks for your help.
Tas
<?xml version="1.0" encoding="UTF-8"?>
<bmc:DeploymentConfiguration xmlns:xsi="http-www.w3.org/2001/XMLSchema-instance" xmlns:bmc="http-model.xxx.xxx.com/myapp/config/2.3" xmlns:bmp="http-model.xxx.xxx.com/buildmonkey/properties/1.0" xmlns:ecore="http-www.eclipse.org/emf/2002/Ecore" xmlns:scripts_1="http-model.xxx.xxx.com/myapp/properties/1.0/scripts/1">
<propertyModels ModelId="scripts">
<enumerations Name="ShellType">
<literals Name="Sh"/>
<literals Name="Bash"/>
</enumerations>
<properties xsi:type="bmp:PrimitiveProperty" Name="Id"/>
<properties xsi:type="bmp:EnumerationProperty" Name="type" type="ShellType"/>
<publishedPackages name="scripts" nsURI="http-model.xxx.xxx.com/myapp/properties/1.0/scripts/1" nsPrefix="scripts_1">
<eClassifiers xsi:type="ecore:EEnum" name="ShellType">
<eLiterals name="Sh"/>
<eLiterals name="Bash"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="scripts">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="Id">
<eType xsi:type="ecore:EDataType" href="http-www.eclipse.org/emf/2002/Ecore#//EString"/>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="//@propertyModels.0/@publishedPackages.0/ShellType"/>
</eClassifiers>
</publishedPackages>
</propertyModels>
<environments name="MyEnvironment">
<deployments xsi:type="bmc:CustomBundleDeployment">
<filesystemTarget/>
<propertyValues xsi:type="scripts_1:scripts"/>
</deployments>
</environments>
</bmc:DeploymentConfiguration>
|
|
|
|
|
Re: What's a good way of serializing/deserializing models with embedded EPackage [message #894944 is a reply to message #894923] |
Wed, 11 July 2012 04:16   |
Eclipse User |
|
|
|
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Tas,<br>
<br>
Comments below.<br>
<br>
<br>
<div class="moz-cite-prefix">On 11/07/2012 8:16 AM, Tas
Frangoullides wrote:<br>
</div>
<blockquote cite="mid:jtj5nd$ikb$1@xxxxxxxxe.org" type="cite">Hi
Ed,
<br>
Thanks for the response. Maybe I did't explain too well the file
contents. The EPackage does come before the instances of the
eClass declared within it.</blockquote>
Sorry, my fault, I didn't look so closely.<br>
<blockquote cite="mid:jtj5nd$ikb$1@xxxxxxxxe.org" type="cite"> I
can understand that it needs to be that way. So to do the loading
it sounds like registering the EPackage as it is encountered is
the way to go. My question is really asking the right way to do
that. Should I use an XML handler?
<br>
</blockquote>
I wonder if just using this option will solve the problem...<small><br>
</small>
<blockquote><small> /**</small><br>
<small> * Produce an
xsi:schemaLocation/xsi:noNamespaceSchemaLocation in the saved
result.</small><br>
<small> */</small><br>
<small> String OPTION_SCHEMA_LOCATION = "SCHEMA_LOCATION";</small><br>
</blockquote>
I'd expect to result in an xsi:schemaLocation attribute that
specifies the location of the package within this resource and that
by the time it needs to be resolved, i.e., while processing the
xsi:type in <propertyValues xsi:type="scripts_1:scripts"/>, it
should be attached to the resource's content tree and be available
for use.<br>
<br>
Please try that first and let me know who it goes.<br>
<blockquote cite="mid:jtj5nd$ikb$1@xxxxxxxxe.org" type="cite">Thanks,
<br>
Tas.
<br>
</blockquote>
<br>
<br>
</body>
</html>
|
|
|
|
Powered by
FUDForum. Page generated in 0.05228 seconds