MoDisco changing Model Load behavior [message #664871] |
Tue, 12 April 2011 11:01 |
Anders Olsson Messages: 21 Registered: July 2009 |
Junior Member |
|
|
Hi,
What I'm trying to do is load a file according to my Meta-Model from code like so:
ResourceSet resourceSet = new ResourceSetImpl();
Resource myRes = resourceSet.createResource(myFileUri, MyMetaModelPackage.eNS_URI);
myRes.load(null);
EObject myObj = xmlRes.getContents().get(0);
myFileUri points to a file on the local filesystem. MyMetaModelPackage.eNS_URI contins the namespace of the Meta-Model.
In the case where the file extension is the expected (the one specified in the genmodel), things work as expected. myRes gets loaded as an XMIResource and myObj is of the expected Meta-Model type.
However if myFileUri points to a file with identical content, but with a different file extension, things behave differently. Then myRes gets the type 'org.eclipse.gmt.modisco.xml.resource.GenericXMLResourceImpl ' and myObj is a 'org.eclipse.gmt.modisco.xml.emf.impl.RootImpl' with the name of the first element in the model file.
Thing is if I uninstall MoDisco (version 0.8.2.v201102100957) and repeat the process where I load the file with the wrong file extension, things work just normal. I get an XMIResource, and the EObject I get out is of my Meta-Model type.
Is this a known bug in MoDisco, or is it expected behavior? Is there a way I should do my loading so MoDisco doesn't interfere?
Thanks in advance for any clarifications,
Anders
|
|
|
Re: MoDisco changing Model Load behavior [message #664982 is a reply to message #664871] |
Tue, 12 April 2011 16:22 |
Ed Merks Messages: 33252 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060500000507030903090101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Anders,
Even if you make use of content types like the one registered for XMI
<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
* file-extensions="xmi"*
id="org.eclipse.emf.ecore.xmi"
name="%_UI_XMI_content_type"
priority="normal">
<describer
class=" org.eclipse.emf.ecore.xmi.impl.XMLContentHandlerImpl$XMI$Des criber "/>
</content-type>
</extension>
you still need to specify which file extensions to inspect for that type
of content. So it's up to you to ensure you have sufficient
registrations against extensions if that's sufficiently unique or a
combination of content types and extension (if you want to use xml as
your extension for example) to get the behavior you desire.
Anders Olsson wrote:
> Hi,
>
> What I'm trying to do is load a file according to my Meta-Model from
> code like so:
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource myRes = resourceSet.createResource(myFileUri,
> MyMetaModelPackage.eNS_URI);
> myRes.load(null);
> EObject myObj = xmlRes.getContents().get(0);
>
> myFileUri points to a file on the local filesystem.
> MyMetaModelPackage.eNS_URI contins the namespace of the Meta-Model.
>
> In the case where the file extension is the expected (the one
> specified in the genmodel), things work as expected. myRes gets loaded
> as an XMIResource and myObj is of the expected Meta-Model type.
>
> However if myFileUri points to a file with identical content, but with
> a different file extension, things behave differently. Then myRes gets
> the type 'org.eclipse.gmt.modisco.xml.resource.GenericXMLResourceImpl
> ' and myObj is a 'org.eclipse.gmt.modisco.xml.emf.impl.RootImpl' with
> the name of the first element in the model file.
>
> Thing is if I uninstall MoDisco (version 0.8.2.v201102100957) and
> repeat the process where I load the file with the wrong file
> extension, things work just normal. I get an XMIResource, and the
> EObject I get out is of my Meta-Model type.
>
> Is this a known bug in MoDisco, or is it expected behavior? Is there a
> way I should do my loading so MoDisco doesn't interfere?
>
> Thanks in advance for any clarifications,
>
> Anders
--------------060500000507030903090101
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Anders,<br>
<br>
Even if you make use of content types like the one registered for XMI<br>
<br>
<small> <extension<br>
point="org.eclipse.core.contenttype.contentTypes"><br >
<content-type<br>
base-type="org.eclipse.core.runtime.xml"<br>
<b> file-extensions="xmi"</b><br>
id="org.eclipse.emf.ecore.xmi"<br>
name="%_UI_XMI_content_type"<br>
priority="normal"><br>
<describer
class=" org.eclipse.emf.ecore.xmi.impl.XMLContentHandlerImpl$XMI$Des criber "/><br>
</content-type><br>
</extension></small><br>
<br>
you still need to specify which file extensions to inspect for that
type of content. So it's up to you to ensure you have sufficient
registrations against extensions if that's sufficiently unique or a
combination of content types and extension (if you want to use xml as
your extension for example) to get the behavior you desire.<br>
<br>
<br>
Anders Olsson wrote:
<blockquote cite="mid:io1avg$n8l$1@news.eclipse.org" type="cite">Hi,
<br>
<br>
What I'm trying to do is load a file according to my Meta-Model from
code like so:
<br>
ResourceSet resourceSet = new ResourceSetImpl();
<br>
Resource myRes = resourceSet.createResource(myFileUri,
MyMetaModelPackage.eNS_URI);
<br>
myRes.load(null);
<br>
EObject myObj = xmlRes.getContents().get(0);
<br>
<br>
myFileUri points to a file on the local filesystem.
MyMetaModelPackage.eNS_URI contins the namespace of the Meta-Model.
<br>
<br>
In the case where the file extension is the expected (the one specified
in the genmodel), things work as expected. myRes gets loaded as an
XMIResource and myObj is of the expected Meta-Model type.
<br>
<br>
However if myFileUri points to a file with identical content, but with
a different file extension, things behave differently. Then myRes gets
the type 'org.eclipse.gmt.modisco.xml.resource.GenericXMLResourceImpl
' and myObj is a 'org.eclipse.gmt.modisco.xml.emf.impl.RootImpl' with
the name of the first element in the model file.
<br>
<br>
Thing is if I uninstall MoDisco (version 0.8.2.v201102100957) and
repeat the process where I load the file with the wrong file extension,
things work just normal. I get an XMIResource, and the EObject I get
out is of my Meta-Model type.
<br>
<br>
Is this a known bug in MoDisco, or is it expected behavior? Is there a
way I should do my loading so MoDisco doesn't interfere?
<br>
<br>
Thanks in advance for any clarifications,
<br>
<br>
Anders
<br>
</blockquote>
</body>
</html>
--------------060500000507030903090101--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03404 seconds