Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » DocumentRoot is generated in final XML
DocumentRoot is generated in final XML [message #1408655] Fri, 15 August 2014 17:58 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
I was working on my model and wrote substantial supporting code around it. After needed regen my XML contains DocumentRoot in it:

<?xml version="1.0" encoding="UTF-8"?>
<rep:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:rep="http://repo.com/xml/repository">
  <rChannel description="" name="ww" targetServer="7.0.2-SNAPSHOT" uid="161FC3B35274C9963FA4DAD0574DF550"/>
</rep:DocumentRoot>


I am not sure what caused it, and I remember I fix this in the past, but don't remember what I did. I have different roots of the model created into separate files and all of them, including above mentioned channel element using the same code:

protected abstract EReference getModelEReference();
	
protected EObject createInitialModel(String guid) {
	EClass eClass = ExtendedMetaData.INSTANCE.getDocumentRoot(channelPackage);
	EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(getModelEReference().getName());
	EObject rootObject = channelFactory.create(eClass);
		
	rootObject.eSet(eStructuralFeature, EcoreUtil.create((EClass)eStructuralFeature.getEType()));
	EObject feature = (EObject) rootObject.eGet(eStructuralFeature);
		
	feature.eSet(ChannelPackage.eINSTANCE.getComponent_Name(), (String) model.get(AbstractIWResourceGeneralPropertiesPage.RESOURCE_NAME));
	feature.eSet(ChannelPackage.eINSTANCE.getComponent_Description(), (String) model.get(AbstractIWResourceGeneralPropertiesPage.RESOURCE_DESC));
	feature.eSet(ChannelPackage.eINSTANCE.getComponent_TargetServer(), (String) model.get(AbstractIWResourceGeneralPropertiesPage.RESOURCE_TARGET_VERSION));
	feature.eSet(ChannelPackage.eINSTANCE.getComponent_Uid(), guid);
		
	return rootObject;
	}


I think it's something minor I overlooked. Any help is appreciated.

[Updated on: Fri, 15 August 2014 17:59]

Report message to a moderator

Re: DocumentRoot is generated in final XML [message #1408958 is a reply to message #1408655] Sat, 16 August 2014 16:33 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 150
Registered: February 2012
Senior Member
Serrizlization result depends on what resource implementation you're using, and not model itself is created. So, code with resource/resourceSet instantiation would be more uselful.

From what I see in you serrialized model - it's an XMI resource, not an XML. Chech resource instances you're using, and resource factory registrations (including file extensions).
Re: DocumentRoot is generated in final XML [message #1410072 is a reply to message #1408958] Tue, 19 August 2014 18:53 Go to previous message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
Thanks Leonid,

I found the problem thanks to your hits. I was moving code around and somewhere down the line omitted org.eclipse.emf.ecore.extension_parser that maps file extension to resource factory. Once I defined it everything worked.
Previous Topic:CDO Timeout Exception
Next Topic:Hiding menu items from context menu of generated editor
Goto Forum:
  


Current Time: Fri Apr 26 06:13:36 GMT 2024

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

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

Back to the top