Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » XSD to EMF(Model instance not persisting)
XSD to EMF [message #484564] Tue, 08 September 2009 09:25 Go to next message
James Williams is currently offline James WilliamsFriend
Messages: 27
Registered: July 2009
Junior Member
Hi all,

I followed this tutorial ( http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.doc/tutorials/xlibmod/xlibmod.html) to create an EMF model from an XSD. I didn't want a custom editor or anything so stopped after that.

I have my ecore file sitting happily in my project and I register the EPackage, which works fine. I then create an Epsilon EMF Model from the wizard, choosing my newly registered EPackage as the metamodel uri. The model file is created fine, and I can add the expected elements into the model. However, these elements do not persist once the file is closed and reopened - leaving just the root node and no child nodes.

Creating a model instance of a pre-registered metamodel (such as UML2) works fine. Is there possibly something wrong with the way the XSD is transformed. Maybe this should go into the EMF forum?

The XSD is here: http://czt.sourceforge.net/zml/zml/Z_2_1.xsd

Cheers,

James
Re: XSD to EMF [message #484574 is a reply to message #484564] Tue, 08 September 2009 10:25 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

This may be an issue related to Exeed. Could you please name your model
..xmi or .ecore and try to edit it with the built-in reflective editor
and let me know what happens?

Cheers,
Dimitris

James Williams wrote:
> Hi all,
>
> I followed this tutorial
> ( http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.doc/tutorials/xlibmod/xlibmod.html)
> to create an EMF model from an XSD. I didn't want a custom editor or
> anything so stopped after that.
>
> I have my ecore file sitting happily in my project and I register the
> EPackage, which works fine. I then create an Epsilon EMF Model from the
> wizard, choosing my newly registered EPackage as the metamodel uri. The
> model file is created fine, and I can add the expected elements into the
> model. However, these elements do not persist once the file is closed
> and reopened - leaving just the root node and no child nodes.
>
> Creating a model instance of a pre-registered metamodel (such as UML2)
> works fine. Is there possibly something wrong with the way the XSD is
> transformed. Maybe this should go into the EMF forum?
>
> The XSD is here: http://czt.sourceforge.net/zml/zml/Z_2_1.xsd
>
> Cheers,
>
> James


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: XSD to EMF [message #484577 is a reply to message #484574] Tue, 08 September 2009 10:55 Go to previous messageGo to next message
James Williams is currently offline James WilliamsFriend
Messages: 27
Registered: July 2009
Junior Member
Hi Dimitris,

When opening it with the Sample Reflective Ecore Model Editor (as either .xmi or .ecore), I get the following (trimmed as they were massive) errors:

Quote:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect' not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
at ........



and

Quote:

org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect' not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
at ........



Cheers,

James
Re: XSD to EMF [message #484581 is a reply to message #484577] Tue, 08 September 2009 11:06 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

Thanks for the update. I'll give the xsd a go and get back to you.

Cheers,
Dimitris

James Williams wrote:
> Hi Dimitris,
>
> When opening it with the Sample Reflective Ecore Model Editor (as either
> .xmi or .ecore), I get the following (trimmed as they were massive) errors:
>
> Quote:
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
>> ticWrappedException:
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>> at ........
>
>
> and
>
> Quote:
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>> at ........
>
>
> Cheers,
>
> James


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: XSD to EMF [message #484586 is a reply to message #484581] Tue, 08 September 2009 11:32 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Just so as not to leave this thread hanging. This has been resolved
off-line and the short story is that when creating a model from an Ecore
that has been generated from an XSD, in the New EMF Model wizard of
Epsilon, you should select DocumentRoot as the Root Instance type and
add all other objects below that.

Cheers,
Dimitris

Dimitris Kolovos wrote:
> Hi James,
>
> Thanks for the update. I'll give the xsd a go and get back to you.
>
> Cheers,
> Dimitris
>
> James Williams wrote:
>> Hi Dimitris,
>>
>> When opening it with the Sample Reflective Ecore Model Editor (as
>> either .xmi or .ecore), I get the following (trimmed as they were
>> massive) errors:
>>
>> Quote:
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
>>> ticWrappedException:
>>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>>> at ........
>>
>>
>> and
>>
>> Quote:
>>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>>> at ........
>>
>>
>> Cheers,
>>
>> James
>
>


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: XSD to EMF [message #580442 is a reply to message #484574] Tue, 08 September 2009 10:55 Go to previous messageGo to next message
James Williams is currently offline James WilliamsFriend
Messages: 27
Registered: July 2009
Junior Member
Hi Dimitris,

When opening it with the Sample Reflective Ecore Model Editor (as either .xmi or .ecore), I get the following (trimmed as they were massive) errors:

Quote:
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect' not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
> at ........


and

Quote:
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect' not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
> at ........


Cheers,

James
Re: XSD to EMF [message #580480 is a reply to message #580442] Tue, 08 September 2009 11:06 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

Thanks for the update. I'll give the xsd a go and get back to you.

Cheers,
Dimitris

James Williams wrote:
> Hi Dimitris,
>
> When opening it with the Sample Reflective Ecore Model Editor (as either
> .xmi or .ecore), I get the following (trimmed as they were massive) errors:
>
> Quote:
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
>> ticWrappedException:
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>> at ........
>
>
> and
>
> Quote:
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>> at ........
>
>
> Cheers,
>
> James


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: XSD to EMF [message #580492 is a reply to message #484581] Tue, 08 September 2009 11:32 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Just so as not to leave this thread hanging. This has been resolved
off-line and the short story is that when creating a model from an Ecore
that has been generated from an XSD, in the New EMF Model wizard of
Epsilon, you should select DocumentRoot as the Root Instance type and
add all other objects below that.

Cheers,
Dimitris

Dimitris Kolovos wrote:
> Hi James,
>
> Thanks for the update. I'll give the xsd a go and get back to you.
>
> Cheers,
> Dimitris
>
> James Williams wrote:
>> Hi Dimitris,
>>
>> When opening it with the Sample Reflective Ecore Model Editor (as
>> either .xmi or .ecore), I get the following (trimmed as they were
>> massive) errors:
>>
>> Quote:
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
>>> ticWrappedException:
>>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>>> at ........
>>
>>
>> and
>>
>> Quote:
>>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'zSect'
>>> not found. (platform:/resource/ZML/model/birthdaybook.xmi, 3, 43)
>>> at ........
>>
>>
>> Cheers,
>>
>> James
>
>


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: XSD to EMF [message #1404043 is a reply to message #484586] Tue, 29 July 2014 10:01 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi,

I'd like to pick up this thread as I've got the same feature not found exception.
I get it due to upper case letters in XML tags, while loading a XML instance for an ecore model.

Starting from a very simple XML Scheme File MyXSD.xml
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="MyXSD" xmlns:xs="..." elementFormDefault="qualified" targetNamespace="MyXSD">
    <xs:element name="Document" type="Document"/>
    <xs:complexType name="Document">
        <xs:sequence>
            <xs:element name="FirstElem" type="Max10Text"/>
            <xs:element name="SecondElem" type="Max20Text"/>
        </xs:sequence>
   </xs:complexType>
    <xs:simpleType name="Max10Text"> ... </xs:simpleType>
    <xs:simpleType name="Max20Text"> ... </xs:simpleType>
</xs:schema>

I have got ecore and genmodel, generated editors and everything works fine.

By ANT script, I register my ecore model and I try to load the following XML instance in Epsilon:
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="MyXSD" xmlns:xsi="...">
       <FirstElem>FirstElem</FirstElem>
       <SecondElem>SecondElement</SecondElem>
</Document>

At this step, I get a feature not found exception "Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'FirstElem' not found."

Changing the first letter of inner element tags from upper case to lower case, loading of this instance succeeds.
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="MyXSD" xmlns:xsi="...">
       <firstElem>FirstElem</firstElem>
       <secondElem>SecondElement</secondElem>
</Document>


Exceed editor and Eclipse Validation, of course, accept the first version of this file and complain about the second version with lower case letters.

May be, I am missing some parameter for loading the XML instance or any other detail?
Do you need any additional information?

Thanks in advance,
Gerd


eclipse-epsilon-1.1_SR1-win32-x86_64
Windows 7 64 bit with Java 1.7 update 60

Re: XSD to EMF [message #1404138 is a reply to message #1404043] Tue, 29 July 2014 21:48 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

Could you please attach the exact XSD/XML files you're using so that I can try to reproduce this locally?

Cheers,
Dimitris
Re: XSD to EMF [message #1404168 is a reply to message #1404138] Wed, 30 July 2014 08:04 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

yes, of course.
Here they are.

Thanks for your help,
Gerd
Re: XSD to EMF [message #1404175 is a reply to message #1404168] Wed, 30 July 2014 09:00 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

I haven't been able to reproduce this in my setup (Epsilon loads the uppercase file without problems but reports errors with the lowercase file - as expected). Could you please share the complete projects?

Cheers,
Dimitris
Re: XSD to EMF [message #1404194 is a reply to message #1404175] Wed, 30 July 2014 10:45 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

attached MyXSD projects (including edit, editor and tests project).

In the core project MyXSD, you will find the model folder, an instances folder and the ANT script launch.xml, which yields the Feature Not Found Exception.
The exception is documented in a plain text file as well.

Thank you and best regards,
Gerd
  • Attachment: MyXSD.zip
    (Size: 66.03KB, Downloaded 154 times)
Re: XSD to EMF [message #1404382 is a reply to message #1404194] Thu, 31 July 2014 19:27 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

Replacing your epsilon.emf.loadModel task with the following seems to be doing the trick:

<epsilon.emf.loadXmlModel name="MyXSD" modelfile="instances/MyXSDInstance.upperCase.xml" xsdfile="model/MyXSD.xsd" read="true" store="false"/>

Cheers,
Dimitris
Re: XSD to EMF [message #1404450 is a reply to message #484564] Fri, 01 August 2014 13:23 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

thanks for your help.

Changing my ANT script according to your post, I run into a familiar ANT error with this line:
BUILD FAILED
F:\EpsilonWS\MyXSD\launch.xml:23: The following error occurred while executing this line:
F:\EpsilonWS\MyXSD\launch.xml:25: Problem: failed to create task or type epsilon.emf.loadXmlModel
Cause: The name is undefined.


I didn't do any other changes in my project.
ANT settings are set to run in the same JRE as the Workspace.

So, if it works in your setup and does not work in mine, I am a little bit clueless.
Do you have an idea?

Thank you and best regards,
Gerd
Re: XSD to EMF [message #1404500 is a reply to message #1404450] Sat, 02 August 2014 09:12 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

It appears that this task was introduced after the latest stable version (1.1_SR1) was released, so to use it you'd need to install the latest interim version of Epsilon from [1].

Cheers,
Dimitris

[1] http://download.eclipse.org/epsilon/interim/
Re: XSD to EMF [message #1404701 is a reply to message #1404500] Tue, 05 August 2014 07:20 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

now, it works fine. Smile
Thanks a lot for your help.

Best regards,
Gerd
Re: XSD to EMF [message #1413019 is a reply to message #1404701] Wed, 27 August 2014 15:20 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

using Epsilon 1.2, I'm aiming for a Java standalone application.
If I use createEmfModel(..) as in your standalone example, I get the same feature not found exception as before (29/07).

So, switching from ANT to Java, I'd like to know:
How do I import XML instances with reference to a XML scheme (xsd) files (instead of ecore model)?
Is it just some parameter to be set or do I need another method?

Thanks for your help and best regards,
Gerd


Re: XSD to EMF [message #1413485 is a reply to message #1413019] Thu, 28 August 2014 16:41 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

You'll need to use the XmlModel specialisation of EmfModel. Something like the following should do the trick:

import java.io.File;

import org.eclipse.epsilon.common.util.StringProperties;
import org.eclipse.epsilon.emc.emf.xml.XmlModel;

public class App {
	
	public static void main(String[] args) throws Exception {
		
		XmlModel model = new XmlModel();
		StringProperties sp = new StringProperties();
		sp.put(XmlModel.PROPERTY_NAME, "M");
		sp.put(XmlModel.PROPERTY_READONLOAD, true);
		sp.put(XmlModel.PROPERTY_STOREONDISPOSAL, false);
		sp.put(XmlModel.PROPERTY_XSD_FILE, <XSD absolute path>);
		sp.put(XmlModel.PROPERTY_MODEL_FILE, <XML absolute path>);
		model.load(sp, null);
		
		System.out.println(model.getAllOfKind(<Some type>));
	}
}


Cheers,
Dimitris
Re: XSD to EMF [message #1416059 is a reply to message #1413485] Thu, 04 September 2014 08:42 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

thank you for your time and your helpful answers.
While model and instance loading works fine - thanks to your help - I'm trying live validation in a GMF model editor by means of EVL.

Following your example and screencast
https://www.eclipse.org/epsilon/doc/articles/evl-gmf-integration/
https://www.youtube.com/watch?v=lWlNw7A1tEg
I have created a new plugin project containing my evl file (org.example.myxsd.zip).
Basic model project MyXSD is added as well (MyXSD.zip).

Running a new instance with this plugin, validation fails with a runtime error during evaluation of my evl file:
"Cannot find meta-class 'Document' in model 'MyXSD'" (cf. screenshot attached).

May be, this error is connected to the upper case/lower case topic before?

Any helpful hint will be appreciated. Smile

Best regards,
Gerd


Running:
Epsilon 1.2 64bit package (eclipse-epsilon-1.2-win32-x86_64)
with Java7 update67 64bit on Windows7 Pro 64bit
Re: XSD to EMF [message #1416071 is a reply to message #1416059] Thu, 04 September 2014 09:12 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

You should either set the modelName attribute of your EVL extension to "MyXSD", or omit the MyXSD! prefix in your .evl file.

Cheers,
Dimitris
Re: XSD to EMF [message #1416076 is a reply to message #1416071] Thu, 04 September 2014 09:23 Go to previous messageGo to next message
Gerd Wierse is currently offline Gerd WierseFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Dimitris,

oh, of course.
Should have found it myself. Embarrassed

Thanks a lot for your quick response.

Best regards,
Gerd
Re: XSD to EMF [message #1417396 is a reply to message #1416076] Fri, 05 September 2014 10:23 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Gerd,

No worries. I'm glad this helped.

Cheers,
Dimitris
Previous Topic:[EOL/ECL] How can I store data in a tabular way?
Next Topic:[EOL/ECL] 'add()' method not known for type 'Set'?
Goto Forum:
  


Current Time: Thu Apr 25 09:10:41 GMT 2024

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

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

Back to the top