Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » OPTION_SCHEMA_LOCATION has no effect
OPTION_SCHEMA_LOCATION has no effect [message #1012268] Thu, 21 February 2013 03:35 Go to next message
sakop qq is currently offline sakop qq
Messages: 29
Registered: January 2013
Junior Member
Hi,

In order to avoid the EPackage not found exception, I am saving xmi files using the option OPTION_SCHEMA_LOCATION:

Map options = new HashMap();
options.put(XMLResource.OPTION_SCHEMA_LOCATION,Boolean.TRUE);
file1.save(options);


Sometimes, it works fine since I can see the schemaLocation attribute in the generated file, however, there are still some occasions that this attribute is not generated, can sb tell me why?

Thanks
Re: OPTION_SCHEMA_LOCATION has no effect [message #1012294 is a reply to message #1012268] Thu, 21 February 2013 04:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Maybe this answers the question:<br>
<br>
<li class="toclevel-2"><a
href="http://wiki.eclipse.org/index.php/EMF-FAQ#How_can_I_ensure_that_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></li>
<br>
<div class="moz-cite-prefix">On 21/02/2013 9:35 AM, sakop qq wrote:<br>
</div>
<blockquote cite="mid:kg4m86$sh9$1@xxxxxxxxe.org" type="cite">Hi,
<br>
<br>
In order to avoid the EPackage not found exception, I am saving
xmi files using the option OPTION_SCHEMA_LOCATION:
<br>
<br>
Map options  = new HashMap();
<br>
       
options.put(XMLResource.OPTION_SCHEMA_LOCATION,Boolean.TRUE);
<br>
        file1.save(options);
<br>
<br>
<br>
Sometimes, it works fine since I can see the schemaLocation
attribute in the generated file, however, there are still some
occasions that this attribute is not generated, can sb tell me
why?
<br>
<br>
Thanks
<br>
</blockquote>
<br>
</body>
</html>
Re: OPTION_SCHEMA_LOCATION has no effect [message #1012716 is a reply to message #1012294] Fri, 22 February 2013 00:03 Go to previous messageGo to next message
sakop qq is currently offline sakop qq
Messages: 29
Registered: January 2013
Junior Member
It is really kind of you!

I have another question, would you please take a look at it?

I serialized a dynamic model,and below is a snippet of a EReference

<eStructuralFeatures xsi:type="ecore:EReference" name="items" upperBound="-1"
eType="ecore:EClass dynamic.ecore#//Item" containment="true" eOpposite="dynamic.ecore#//Item/order"/>

note that the eOpposite attribute has the segment "dynamic.ecore" before "#",however, the Eclass Item is declared within the same EPackage,namely in the same ecore file。

I expected the result to be as:
<eStructuralFeatures xsi:type="ecore:EReference" name="items" upperBound="-1"
eType="ecore:EClass dynamic.ecore#//Item" containment="true" eOpposite="#//Item/order"/>

How can I solve it? Do I need to declare a certion option when saving it?

Thanks.
Re: OPTION_SCHEMA_LOCATION has no effect [message #1012809 is a reply to message #1012716] Fri, 22 February 2013 04:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
Comments below.

On 22/02/2013 6:03 AM, sakop qq wrote:
> It is really kind of you!
>
> I have another question, would you please take a look at it?
>
> I serialized a dynamic model,and below is a snippet of a EReference
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="items"
> upperBound="-1"
> eType="ecore:EClass dynamic.ecore#//Item" containment="true"
> eOpposite="dynamic.ecore#//Item/order"/>
>
> note that the eOpposite attribute has the segment "dynamic.ecore"
> before "#",however, the Eclass Item is declared within the same
> EPackage,namely in the same ecore file。
Perhaps you loaded the resource with a non absolute? That's almost
always a bad idea.
>
> I expected the result to be as:
> <eStructuralFeatures xsi:type="ecore:EReference" name="items"
> upperBound="-1"
> eType="ecore:EClass dynamic.ecore#//Item" containment="true"
> eOpposite="#//Item/order"/>
>
> How can I solve it? Do I need to declare a certion option when saving
> it?
If you load/create the resource with an absolute URI I don't think
you'll see what you're expecting/hoping to see.
>
> Thanks.
Re: OPTION_SCHEMA_LOCATION has no effect [message #1013391 is a reply to message #1012809] Sat, 23 February 2013 09:56 Go to previous messageGo to next message
sakop qq is currently offline sakop qq
Messages: 29
Registered: January 2013
Junior Member
So how can I persist the resource file in a relative way?

What I wanted to do is just eliminating the "segment" in the "eOpposite" attribute,how can I do that?
Re: OPTION_SCHEMA_LOCATION has no effect [message #1013417 is a reply to message #1013391] Sat, 23 February 2013 11:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
What is the URI of the resource you serialized?

On 23/02/2013 3:56 PM, sakop qq wrote:
> So how can I persist the resource file in a relative way?
>
> What I wanted to do is just eliminating the "segment" in the
> "eOpposite" attribute,how can I do that?
Re: OPTION_SCHEMA_LOCATION has no effect [message #1013438 is a reply to message #1013417] Sat, 23 February 2013 12:00 Go to previous messageGo to next message
sakop qq is currently offline sakop qq
Messages: 29
Registered: January 2013
Junior Member
Resource r = rset.createResource(URI.createURI("dynamic.ecore"));

Thanks!
Re: OPTION_SCHEMA_LOCATION has no effect [message #1013442 is a reply to message #1013438] Sat, 23 February 2013 12:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
Sakop,

That's what I thought and that why I told you to use an absolute URI.
If you're writing this to the workspace, you should use
URI.createPlatformResourceURI with the full path in the workspace; see
the FAQ. If you're running stand alone, you should use
URI.createFileURI with an absolute path in the file system, e.g., as
created by File.getAbsolutePath().


On 23/02/2013 6:00 PM, sakop qq wrote:
> Resource r = rset.createResource(URI.createURI("dynamic.ecore"));
>
> Thanks!
Re: OPTION_SCHEMA_LOCATION has no effect [message #1014162 is a reply to message #1013442] Mon, 25 February 2013 04:27 Go to previous message
sakop qq is currently offline sakop qq
Messages: 29
Registered: January 2013
Junior Member
Thanks anyway,I think it works
Previous Topic:Generating ER Diagrams from UML
Next Topic:[CDO/Hibernate] Unable to read xml
Goto Forum:
  


Current Time: Thu Aug 21 18:15:48 EDT 2014

Powered by FUDForum. Page generated in 0.02721 seconds