Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF XMl save config
EMF XMl save config [message #1087762] Fri, 16 August 2013 04:13 Go to next message
vetrivendhan rajamanoharan is currently offline vetrivendhan rajamanoharan
Messages: 1
Registered: August 2013
Junior Member
We are using org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl for saving some configurations of our application to XML

Resource classResource = resourceSet.createResource(classURI);
classResource.getContents().add(cfg);
HashMap options = new HashMap();
options.put(XMLResource.OPTION_DECLARE_XML, Boolean.FALSE);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
classResource.save(bout, options);
bout.flush();

Consider the following scenarios :
Scenario 1 :
Configuration in UI : /<
XML Store format :
<flavor name="Flavor 1" index="149" flavorType="HTTP_URL">
<httpUrl uriPrefix="/&lt;"/>
</flavor>

If reopen the above file, its opening fine
Scenario 2 :
Configuration in UI : />
<flavor name="Flavor 1" index="149" flavorType="HTTP_URL">
<httpUrl uriPrefix="/>"/>
</flavor>

Reopens with following exception:
An internal error occurred during: "Opening Service Configuration File".
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: XML document structures must start and end within the same entity.

How can i make the above condition to write in the XML as
<flavor name="Flavor 1" index="149" flavorType="HTTP_URL">
<httpUrl uriPrefix="/&gt;"/>
</flavor>

Looking for your advice.

Thanks,
Vetri
Re: EMF XMl save config [message #1088151 is a reply to message #1087762] Fri, 16 August 2013 17:08 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
I can't reproduce this. I can read files that look like this:

<workingsets:WorkingSetGroup xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:workingsets="http://www.eclipse.org/CDO/releng/workingsets/1.0">
<workingSets name="/>"/>
</workingsets:WorkingSetGroup>

But your first case looks wrong and is serialized like this when I test.

<workingsets:WorkingSetGroup xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:workingsets="http://www.eclipse.org/CDO/releng/workingsets/1.0">
<workingSets name="/&lt;"/>
</workingsets:WorkingSetGroup>

So I expect the first one of fail (though EMF will not to produce that
when I test) and the second one looks fine and works for me.

On 16/08/2013 3:50 PM, vetrivendhan rajamanoharan wrote:
> We are using org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl for saving
> some configurations of our application to XML
>
> Resource classResource = resourceSet.createResource(classURI);
> classResource.getContents().add(cfg);
> HashMap options = new HashMap();
> options.put(XMLResource.OPTION_DECLARE_XML, Boolean.FALSE);
> ByteArrayOutputStream bout = new ByteArrayOutputStream();
> classResource.save(bout, options);
> bout.flush();
>
> Consider the following scenarios :
> Scenario 1 :
> Configuration in UI : /<
> XML Store format :
> <flavor name="Flavor 1" index="149" flavorType="HTTP_URL">
> <httpUrl uriPrefix="/<"/>
> </flavor>
>
> If reopen the above file, its opening fine
> Scenario 2 :
> Configuration in UI : />
> <flavor name="Flavor 1" index="149" flavorType="HTTP_URL">
> <httpUrl uriPrefix="/>"/>
> </flavor>
>
> Reopens with following exception:
> An internal error occurred during: "Opening Service Configuration File".
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: XML
> document structures must start and end within the same entity.
>
> How can i make the above condition to write in the XML as <flavor
> name="Flavor 1" index="149" flavorType="HTTP_URL">
> <httpUrl uriPrefix="/>"/>
> </flavor>
>
> Looking for your advice.
>
> Thanks,
> Vetri
Previous Topic:[CDO] Problems running cdo-server-Windows
Next Topic:Adding popup menu submenu similar to New Child
Goto Forum:
  


Current Time: Fri Oct 31 07:59:32 GMT 2014

Powered by FUDForum. Page generated in 0.01823 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software