Home » Modeling » EMF » PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor
PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor [message #646429] |
Fri, 24 December 2010 01:23  |
Eclipse User |
|
|
|
I can open XMI files with or without xsi:schemaLocation just fine from
my application, because my application register the package(s) to the
EMF package registry.
However upon saving the resource ("someXMIResource.save(null)") it
removes xsi:schemaLocation from the the .xmi file, making it ineditable
using Eclipse IDE's EMF Editor.
Re-adding schemaLocation works (see
http://eclipsedriven.blogspot.com/2010/12/solving-inside-ecl ipse-
ide.html ), however I'm tired of doing this again and again.
Is there a way to:
1. Add my package to Eclipse *IDE*'s package registry so that XMI files
without xsi:schemaLocation can still be loaded by EMF editor?
2. Or if #1 is not possible, configure so that XMIResource doesn't
remove the xsi:schemaLocation from the XMI file?
Thank you.
--
Eclipse Driven Rich Application Development -
http://eclipsedriven.blogspot.com/
|
|
|
Re: PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor [message #646434 is a reply to message #646429] |
Fri, 24 December 2010 01:56   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------010609010308000309080505
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hendry,
Comments below.
Hendy Irawan wrote:
> I can open XMI files with or without xsi:schemaLocation just fine from
> my application, because my application register the package(s) to the
> EMF package registry.
>
> However upon saving the resource ("someXMIResource.save(null)") it
> removes xsi:schemaLocation from the the .xmi file, making it ineditable
> using Eclipse IDE's EMF Editor.
>
This option controls whether a schema location is saved:
/**
* Produce an xsi:schemaLocation/xsi:noNamespaceSchemaLocation in
the saved result.
*/
String OPTION_SCHEMA_LOCATION = "SCHEMA_LOCATION";
Generally, for registered packages, there's no need for it...
> Re-adding schemaLocation works (see
> http://eclipsedriven.blogspot.com/2010/12/solving-inside-ecl ipse-
> ide.html ), however I'm tired of doing this again and again.
>
> Is there a way to:
> 1. Add my package to Eclipse *IDE*'s package registry so that XMI files
> without xsi:schemaLocation can still be loaded by EMF editor?
>
Yes, by installing a plugin that registers it.
> 2. Or if #1 is not possible, configure so that XMIResource doesn't
> remove the xsi:schemaLocation from the XMI file?
>
The option mentioned above.
A technique that works too is the fact that the nsURI itself will be
used as a schema location if a registered package isn't found...
> Thank you.
>
>
--------------010609010308000309080505
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hendry,<br>
<br>
Comments below.<br>
<br>
Hendy Irawan wrote:
<blockquote cite="mid:if1dv6$e2k$1@news.eclipse.org" type="cite">
<pre wrap="">I can open XMI files with or without xsi:schemaLocation just fine from
my application, because my application register the package(s) to the
EMF package registry.
However upon saving the resource ("someXMIResource.save(null)") it
removes xsi:schemaLocation from the the .xmi file, making it ineditable
using Eclipse IDE's EMF Editor.
</pre>
</blockquote>
This option controls whether a schema location is saved:<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>
Generally, for registered packages, there's no need for it...<br>
<blockquote cite="mid:if1dv6$e2k$1@news.eclipse.org" type="cite">
<pre wrap="">
Re-adding schemaLocation works (see
<a class="moz-txt-link-freetext" href=" http://eclipsedriven.blogspot.com/2010/12/solving-inside-ecl ipse"> http://eclipsedriven.blogspot.com/2010/12/solving-inside-ecl ipse</a>-
ide.html ), however I'm tired of doing this again and again.
Is there a way to:
1. Add my package to Eclipse *IDE*'s package registry so that XMI files
without xsi:schemaLocation can still be loaded by EMF editor?
</pre>
</blockquote>
Yes, by installing a plugin that registers it.<br>
<blockquote cite="mid:if1dv6$e2k$1@news.eclipse.org" type="cite">
<pre wrap="">2. Or if #1 is not possible, configure so that XMIResource doesn't
remove the xsi:schemaLocation from the XMI file?
</pre>
</blockquote>
The option mentioned above.<br>
<br>
A technique that works too is the fact that the nsURI itself will be
used as a schema location if a registered package isn't found...<br>
<blockquote cite="mid:if1dv6$e2k$1@news.eclipse.org" type="cite">
<pre wrap="">
Thank you.
</pre>
</blockquote>
</body>
</html>
--------------010609010308000309080505--
|
|
|
Re: PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor [message #646471 is a reply to message #646434] |
Fri, 24 December 2010 11:24   |
Eclipse User |
|
|
|
Ed Merks wrote:
>> However upon saving the resource ("someXMIResource.save(null)") it
>> removes xsi:schemaLocation from the the .xmi file, making it
ineditable
>> using Eclipse IDE's EMF Editor.
>>
> This option controls whether a schema location is saved:
>
> /**
> * Produce an xsi:schemaLocation/xsi:noNamespaceSchemaLocation
in
> the saved result.
> */
> String OPTION_SCHEMA_LOCATION = "SCHEMA_LOCATION";
>
> Generally, for registered packages, there's no need for it...
Wow! Thank you! I found it, it's in XMIResource.OPTION_SCHEMA_LOCATION
... SO we use it like:
opts.put(XMIResource.OPTION_SCHEMA_LOCATION, "file:///somefile.ecore");
resource.save(opts);
right?
Amazing! This is exactly what I needed! Thanks Ed.
I need to use it from the Eclipse IDE, and I don't want to install my
plugins yet in the IDE.. esp when the metamodel changes often.
>> Is there a way to:
>> 1. Add my package to Eclipse *IDE*'s package registry so that XMI
files
>> without xsi:schemaLocation can still be loaded by EMF editor?
>>
> Yes, by installing a plugin that registers it.
Thanks! Sounds obvious, but I didn't think of that ;-)
>> 2. Or if #1 is not possible, configure so that XMIResource doesn't
>> remove the xsi:schemaLocation from the XMI file?
>>
> The option mentioned above.
Thanks!
> A technique that works too is the fact that the nsURI itself will be
> used as a schema location if a registered package isn't found...
>> Thank you.
Meaning that if I have a nsURI as
"http://somedomain.com/metamodel.ecore" that actually contains an ecore
metamodel, it works? Thanks!!
Thanks again Ed! And thanks for helping so quickly :)
--
Eclipse Driven Rich Application Development -
http://eclipsedriven.blogspot.com/
|
|
|
Re: PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor [message #646472 is a reply to message #646471] |
Fri, 24 December 2010 11:44   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------060004060606070403060809
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hendy,
No, OPTION_SCHEMA_LOCATION is a boolean option; a serialization can
contain many packages. Be sure to read this FAQ question too.
2.22 How can I ensure that an xsi:schemaLocation is serialized for
my packages?
< http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_t hat_an_xsi:schemaLocation_is_serialized_for_my_packages.3F>
In general, a schema location is saved only if the option is true *and
*the package's containing resource's URI is different from the nsURI.
Also OPTION_SCHEMA_LOCATION_IMPLEMENTATION might be useful for
serialization of generated models that need to be processed in a stand
alone application; it can use Java reflection to find the package
instance eliminating the need to ensure that it's pre-registered in
EPackage.Registry.INSTANCE or ResourceSet.getPackageRegistry().
Hendy Irawan wrote:
> Ed Merks wrote:
>
>
>>> However upon saving the resource ("someXMIResource.save(null)") it
>>> removes xsi:schemaLocation from the the .xmi file, making it
>>>
> ineditable
>
>>> using Eclipse IDE's EMF Editor.
>>>
>>>
>> This option controls whether a schema location is saved:
>>
>> /**
>> * Produce an xsi:schemaLocation/xsi:noNamespaceSchemaLocation
>>
> in
>
>> the saved result.
>> */
>> String OPTION_SCHEMA_LOCATION = "SCHEMA_LOCATION";
>>
>> Generally, for registered packages, there's no need for it...
>>
>
> Wow! Thank you! I found it, it's in XMIResource.OPTION_SCHEMA_LOCATION
> .. SO we use it like:
>
> opts.put(XMIResource.OPTION_SCHEMA_LOCATION, "file:///somefile.ecore");
> resource.save(opts);
>
> right?
>
> Amazing! This is exactly what I needed! Thanks Ed.
>
> I need to use it from the Eclipse IDE, and I don't want to install my
> plugins yet in the IDE.. esp when the metamodel changes often.
>
>
>>> Is there a way to:
>>> 1. Add my package to Eclipse *IDE*'s package registry so that XMI
>>>
> files
>
>>> without xsi:schemaLocation can still be loaded by EMF editor?
>>>
>>>
>> Yes, by installing a plugin that registers it.
>>
>
> Thanks! Sounds obvious, but I didn't think of that ;-)
>
>
>>> 2. Or if #1 is not possible, configure so that XMIResource doesn't
>>> remove the xsi:schemaLocation from the XMI file?
>>>
>>>
>> The option mentioned above.
>>
>
> Thanks!
>
>
>> A technique that works too is the fact that the nsURI itself will be
>> used as a schema location if a registered package isn't found...
>>
>>> Thank you.
>>>
>
> Meaning that if I have a nsURI as
> "http://somedomain.com/metamodel.ecore" that actually contains an ecore
> metamodel, it works? Thanks!!
>
> Thanks again Ed! And thanks for helping so quickly :)
>
>
--------------060004060606070403060809
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hendy,<br>
<br>
No, OPTION_SCHEMA_LOCATION is a boolean option; a serialization can
contain many packages. Be sure to read this FAQ question too.<br>
<blockquote><a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_t hat_an_xsi:schemaLocation_is_serialized_for_my_packages.3F"><span
class="tocnumber">2.22</span> <span class="toctext">How can I ensure
that an xsi:schemaLocation is serialized for my packages?</span></a><br>
</blockquote>
In general, a schema location is saved only if the option is true <b>and
</b>the package's containing resource's URI is different from the
nsURI. Also OPTION_SCHEMA_LOCATION_IMPLEMENTATION might be useful for
serialization of generated models that need to be processed in a stand
alone application; it can use Java reflection to find the package
instance eliminating the need to ensure that it's pre-registered in
EPackage.Registry.INSTANCE or ResourceSet.getPackageRegistry().<br>
<br>
<br>
Hendy Irawan wrote:
<blockquote cite="mid:if2h6a$vku$1@news.eclipse.org" type="cite">
<pre wrap="">Ed Merks wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">However upon saving the resource ("someXMIResource.save(null)") it
removes xsi:schemaLocation from the the .xmi file, making it
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->ineditable
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">using Eclipse IDE's EMF Editor.
</pre>
</blockquote>
<pre wrap="">This option controls whether a schema location is saved:
/**
* Produce an xsi:schemaLocation/xsi:noNamespaceSchemaLocation
</pre>
</blockquote>
<pre wrap=""><!---->in
</pre>
<blockquote type="cite">
<pre wrap=""> the saved result.
*/
String OPTION_SCHEMA_LOCATION = "SCHEMA_LOCATION";
Generally, for registered packages, there's no need for it...
</pre>
</blockquote>
<pre wrap=""><!---->
Wow! Thank you! I found it, it's in XMIResource.OPTION_SCHEMA_LOCATION
... SO we use it like:
opts.put(XMIResource.OPTION_SCHEMA_LOCATION, <a class="moz-txt-link-rfc2396E" href="file:///somefile.ecore">"file:///somefile.ecore"</a>);
resource.save(opts);
right?
Amazing! This is exactly what I needed! Thanks Ed.
I need to use it from the Eclipse IDE, and I don't want to install my
plugins yet in the IDE.. esp when the metamodel changes often.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Is there a way to:
1. Add my package to Eclipse *IDE*'s package registry so that XMI
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->files
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">without xsi:schemaLocation can still be loaded by EMF editor?
</pre>
</blockquote>
<pre wrap="">Yes, by installing a plugin that registers it.
</pre>
</blockquote>
<pre wrap=""><!---->
Thanks! Sounds obvious, but I didn't think of that ;-)
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">2. Or if #1 is not possible, configure so that XMIResource doesn't
remove the xsi:schemaLocation from the XMI file?
</pre>
</blockquote>
<pre wrap="">The option mentioned above.
</pre>
</blockquote>
<pre wrap=""><!---->
Thanks!
</pre>
<blockquote type="cite">
<pre wrap="">A technique that works too is the fact that the nsURI itself will be
used as a schema location if a registered package isn't found...
</pre>
<blockquote type="cite">
<pre wrap="">Thank you.
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
Meaning that if I have a nsURI as
<a class="moz-txt-link-rfc2396E" href="http://somedomain.com/metamodel.ecore">"http://somedomain.com/metamodel.ecore"</a> that actually contains an ecore
metamodel, it works? Thanks!!
Thanks again Ed! And thanks for helping so quickly :)
</pre>
</blockquote>
</body>
</html>
--------------060004060606070403060809--
|
|
| | | |
Re: PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor [message #1384949 is a reply to message #1384947] |
Tue, 03 June 2014 05:23   |
Eclipse User |
|
|
|
Hendy,
Note that in the latest release of EMF, you can specify this via an
EAnnotation on the EPackage, i.e., like this
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
<details key="schemaLocation"
value="http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/models/Git.ecore"/>
</eAnnotations>
It will generate the EPackage so that this publication location is used.
Furthermore, in the GenPackage, you can specify the "Publication
Location" to generate a dynamic version of the model you can publish.
On 03/06/2014 11:13 AM, Hendy Irawan wrote:
> Spoke too soon. I found it on the link you mentioned. On
> DataPackageImpl.java, add:
>
>
> @Override
> protected Resource createResource(String uri) {
> // assume accessed from bipporeg-model
> return
> super.createResource("../../../org.soluvas.data/src/main/resources/org/soluvas/data/data.ecore");
It's hard to imagine how such a schema location will work nicely in
general... There's clearly some type of assumption that your data.ecore
will be in the workspace, but how that makes sense, I can't guess...
> }
>
>
> Yay!
|
|
| |
Re: PackageNotFoundException opening XMI file without xsi:schemaLocation in EMF Editor [message #1384956 is a reply to message #1384951] |
Tue, 03 June 2014 05:49  |
Eclipse User |
|
|
|
Hendy,
Yes in the EMF 2.10 release, which is already done, and will be part of
Luna at the end of the month.
On 03/06/2014 11:30 AM, Hendy Irawan wrote:
> Ed Merks wrote on Tue, 03 June 2014 05:23
>> Hendy,
>>
>> Note that in the latest release of EMF, you can specify this via an
>> EAnnotation on the EPackage, i.e., like this
>>
>> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
>> <details key="schemaLocation"
>> value="http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/models/Git.ecore"/>
>> </eAnnotations>
>>
>> It will generate the EPackage so that this publication location is used.
>>
>> Furthermore, in the GenPackage, you can specify the "Publication
>> Location" to generate a dynamic version of the model you can publish.
>
>
> Thank you Ed!
>
> I think by "latest" you mean the one shipped with Eclipse 4.4, as I
> can't find it in the GenModel editor UI in Eclipse 4.3.2.
>
> So for now I'll use the Java code approach. When we upgrade to 4.4
> later I'll use the GenModel approach. :)
|
|
|
Goto Forum:
Current Time: Wed May 07 19:09:40 EDT 2025
Powered by FUDForum. Page generated in 0.06653 seconds
|