Skip to main content



      Home
Home » Modeling » EMF » ecore namespace?
ecore namespace? [message #400999] Thu, 11 May 2006 09:31 Go to next message
Eclipse UserFriend
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry">

<xsd:attribute name="key" type="ecore:EString"/>

<xsd:attribute name="value" type="ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David
Re: ecore namespace? [message #401002 is a reply to message #400999] Thu, 11 May 2006 10:08 Go to previous messageGo to next message
Eclipse UserFriend
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be
an EMap, which is a wrapper for java.util.Map and isn't serializeable?


David Michonneau wrote:
> Hi,
>
> I am trying to add this type in my schema file:
>
> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
> name="EStringToDataSetMapEntry">
>
> <xsd:attribute name="key" type="ecore:EString"/>
>
> <xsd:attribute name="value" type="ecore:EMap"/>
>
> </xsd:complexType>
>
> But my XML editor complains
> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
> unresolved
>
> I added this at the beginning of the xsd file:
>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>
> What else am I missing?
>
> Thanks,
>
> David
>
>
>
>
>
Re: ecore namespace? [message #401005 is a reply to message #401002] Thu, 11 May 2006 10:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Thank your for the reply! I guess I can use xsd:string. For the EMap, yes
that's what I need, since I need to access the objects from a key.

Talking about serialization that was my second question. Right now we can't
serialize that thing (for a different reason, it's internally storing java
objects) and it's quite a problem, but I saw there is a EDataType proxy. Can
I use that to write my own serialization?

Basically my class is something like

interface myClass extends EObject
{
public Object getValues();
public void setValues( Object );
}

And those classes instances are stored themselves in the Hashmap.
java.util.HashMap is serializable though, why do you say it isn't?

The value objects are java arrays like double[] , String[] , Calendar[] and
other EMF classes. I can write the logic to serialize them, that's no
problem. Just how I can hook it so that EMF will use it? The EDataType class
seems promising, but I don't know where to start.

Thanks,

David




"Ed Merks" <merks@ca.ibm.com> wrote in message
news:e3vgh6$p18$1@utils.eclipse.org...
> David,
>
> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
> the schemaLocation to do that.
>
> Why not use xsd:string? Are you sure you want the itself value to be an
> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>
> David Michonneau wrote:
>> Hi,
>>
>> I am trying to add this type in my schema file:
>>
>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>> name="EStringToDataSetMapEntry">
>>
>> <xsd:attribute name="key" type="ecore:EString"/>
>>
>> <xsd:attribute name="value" type="ecore:EMap"/>
>>
>> </xsd:complexType>
>>
>> But my XML editor complains
>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>> unresolved
>>
>> I added this at the beginning of the xsd file:
>>
>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>
>> What else am I missing?
>>
>> Thanks,
>>
>> David
>>
>>
>>
>>
>>
Re: ecore namespace? [message #401009 is a reply to message #401002] Thu, 11 May 2006 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:e3vgh6$p18$1@utils.eclipse.org...
> David,
>
> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
> the schemaLocation to do that.
>
> Why not use xsd:string? Are you sure you want the itself value to be an
> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>
> David Michonneau wrote:
>> Hi,
>>
>> I am trying to add this type in my schema file:
>>
>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>> name="EStringToDataSetMapEntry">
>>
>> <xsd:attribute name="key" type="ecore:EString"/>
>>
>> <xsd:attribute name="value" type="ecore:EMap"/>
>>
>> </xsd:complexType>
>>
>> But my XML editor complains
>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>> unresolved
>>
>> I added this at the beginning of the xsd file:
>>
>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>
>> What else am I missing?
>>
>> Thanks,
>>
>> David
>>
>>
>>
>>
>>
Re: ecore namespace? [message #401010 is a reply to message #401005] Thu, 11 May 2006 10:49 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------060109050203080704020303
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

Comments below.

David Michonneau wrote:
> Hi Ed,
>
> Thank your for the reply! I guess I can use xsd:string. For the EMap, yes
> that's what I need, since I need to access the objects from a key.
>
The EDataType for EMap has isSerializable false and hence
createFromString and convertToString are not supported and hence a
feature of this type cannot be serialized by EMF.
> Talking about serialization that was my second question. Right now we can't
> serialize that thing (for a different reason, it's internally storing java
> objects) and it's quite a problem, but I saw there is a EDataType proxy. Can
> I use that to write my own serialization?
>
Yes, you can define your own data type Abc and implement your own create
XyzFactoryImpl.createAbcFromString and convertAbcToString.
> Basically my class is something like
>
> interface myClass extends EObject
> {
> public Object getValues();
> public void setValues( Object );
> }
>
> And those classes instances are stored themselves in the Hashmap.
> java.util.HashMap is serializable though, why do you say it isn't?
>
Because EDataType.isSerializable a different thing.
> The value objects are java arrays like double[] , String[] , Calendar[] and
> other EMF classes. I can write the logic to serialize them, that's no
> problem. Just how I can hook it so that EMF will use it? The EDataType class
> seems promising, but I don't know where to start.
>
Some folks have used java.io.Serializable support to implement their
createAbcFromString and convertAbcToString methods. The idea would be
to serialize to bytes, use perhaps a base64 encoding (you can reuse
XMLTypeFactory.INSTANCE.convertBase64Binary for this) of those bytes as
the string value. Then do the inverse to get the original Java objects
back.
> Thanks,
>
> David
>
>
>
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:e3vgh6$p18$1@utils.eclipse.org...
>
>> David,
>>
>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>> the schemaLocation to do that.
>>
>> Why not use xsd:string? Are you sure you want the itself value to be an
>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>
>> David Michonneau wrote:
>>
>>> Hi,
>>>
>>> I am trying to add this type in my schema file:
>>>
>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>> name="EStringToDataSetMapEntry">
>>>
>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>
>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>
>>> </xsd:complexType>
>>>
>>> But my XML editor complains
>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>> unresolved
>>>
>>> I added this at the beginning of the xsd file:
>>>
>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>
>>> What else am I missing?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>


--------------060109050203080704020303
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">
David,<br>
<br>
Comments below.<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vhbq$rnk$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi Ed,

Thank your for the reply! I guess I can use xsd:string. For the EMap, yes
that's what I need, since I need to access the objects from a key.
</pre>
</blockquote>
The EDataType for EMap has isSerializable false and hence
createFromString and convertToString are not supported and hence a
feature of this type cannot be serialized by EMF.<br>
<blockquote cite="mide3vhbq$rnk$1@utils.eclipse.org" type="cite">
<pre wrap="">
Talking about serialization that was my second question. Right now we can't
serialize that thing (for a different reason, it's internally storing java
objects) and it's quite a problem, but I saw there is a EDataType proxy. Can
I use that to write my own serialization?
</pre>
</blockquote>
Yes, you can define your own data type Abc and implement your own
create XyzFactoryImpl.createAbcFromString and convertAbcToString.<br>
<blockquote cite="mide3vhbq$rnk$1@utils.eclipse.org" type="cite">
<pre wrap="">
Basically my class is something like

interface myClass extends EObject
{
public Object getValues();
public void setValues( Object );
}

And those classes instances are stored themselves in the Hashmap.
java.util.HashMap is serializable though, why do you say it isn't?
</pre>
</blockquote>
Because EDataType.isSerializable a different thing.<br>
<blockquote cite="mide3vhbq$rnk$1@utils.eclipse.org" type="cite">
<pre wrap="">
The value objects are java arrays like double[] , String[] , Calendar[] and
other EMF classes. I can write the logic to serialize them, that's no
problem. Just how I can hook it so that EMF will use it? The EDataType class
seems promising, but I don't know where to start.
</pre>
</blockquote>
Some folks have used java.io.Serializable support to implement their
createAbcFromString and convertAbcToString methods.&nbsp; The idea would be
to serialize to bytes, use perhaps a base64 encoding (you can reuse
XMLTypeFactory.INSTANCE.convertBase64Binary for this) of those bytes as
the string value.&nbsp; Then do the inverse to get the original Java objects
back.<br>
<blockquote cite="mide3vhbq$rnk$1@utils.eclipse.org" type="cite">
<pre wrap="">
Thanks,

David




"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------060109050203080704020303--
Re: ecore namespace? [message #401011 is a reply to message #401009] Thu, 11 May 2006 10:53 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------070404060409070908020709
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

Are you using EMF 2.2? I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:
> Hi,
>
> I did add this line, but it still complains, and the generator too:
>
> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>
> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>
> Thanks,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:e3vgh6$p18$1@utils.eclipse.org...
>
>> David,
>>
>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>> the schemaLocation to do that.
>>
>> Why not use xsd:string? Are you sure you want the itself value to be an
>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>
>> David Michonneau wrote:
>>
>>> Hi,
>>>
>>> I am trying to add this type in my schema file:
>>>
>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>> name="EStringToDataSetMapEntry">
>>>
>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>
>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>
>>> </xsd:complexType>
>>>
>>> But my XML editor complains
>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>> unresolved
>>>
>>> I added this at the beginning of the xsd file:
>>>
>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>
>>> What else am I missing?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>


--------------070404060409070908020709
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">
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------070404060409070908020709--
Re: ecore namespace? [message #401016 is a reply to message #401011] Thu, 11 May 2006 11:38 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_1975_01C67521.B35E4C70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate the model, it =
creates an EMap... I use the following type:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where should it go in =
the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to use schema =
types (xsd:string) and for EMap you'll need to define your own type =
anyway. If you take the approach I outlined of serializing the value =
map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20

------=_NextPart_000_1975_01C67521.B35E4C70
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I reloaded the xml file in the editor =
and it=20
worked!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use java.util.Map, but =
when I=20
generate the model, it creates an EMap... I use the following =
type:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType =
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key" =
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value" =
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded" =
name=3D"DataSets"=20
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a java.util.Map =
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear how to register =
the=20
EDataType, where should it go in the schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better to use schema =
types=20
(xsd:string) and for EMap you'll need to define your own type =
anyway.&nbsp; If=20
you take the approach I outlined of serializing the value map as a =
base64=20
"blob", I'd define a new data type that restricts base64Binary and =
defines the=20
ecore:instanceClass to be java.util.Map.<BR><BR><BR>David Michonneau =
wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org type=3D"cite"><PRE =
wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_1975_01C67521.B35E4C70--
Re: ecore namespace? [message #401017 is a reply to message #401016] Thu, 11 May 2006 11:56 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------070407030405090906020207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API.

For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value". For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map". Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.

Hopefully I've correctly understood that you want a map that maps a
string to another map....


David Michonneau wrote:
> I reloaded the xml file in the editor and it worked!
>
> Now I agree to use java.util.Map, but when I generate the model, it
> creates an EMap... I use the following type:
>
>
> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
> name="EStringToDataSetMapEntry">
>
> <xsd:attribute name="key" type="xsd:string"/>
>
> <xsd:attribute name="value" type="xsd:anyType"/>
>
> </xsd:complexType>
>
> with
>
> <xsd:element maxOccurs="unbounded" name="DataSets"
> type="EStringToDataSetMapEntry">
>
> </xsd:element>
>
> How can I force it to generate a java.util.Map instead?
>
> I'm still not clear how to register the EDataType, where should it go
> in the schema?
>
> Thanks,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:e3vj4q$47o$1@utils.eclipse.org...
> David,
>
> Are you using EMF 2.2? I think you would be better to use schema
> types (xsd:string) and for EMap you'll need to define your own
> type anyway. If you take the approach I outlined of serializing
> the value map as a base64 "blob", I'd define a new data type that
> restricts base64Binary and defines the ecore:instanceClass to be
> java.util.Map.
>
>
> David Michonneau wrote:
>> Hi,
>>
>> I did add this line, but it still complains, and the generator too:
>>
>> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
>> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>>
>> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>>
>> Thanks,
>>
>> David
>>
>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>> news:e3vgh6$p18$1@utils.eclipse.org...
>>
>>> David,
>>>
>>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>>> the schemaLocation to do that.
>>>
>>> Why not use xsd:string? Are you sure you want the itself value to be an
>>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>>
>>> David Michonneau wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to add this type in my schema file:
>>>>
>>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>>> name="EStringToDataSetMapEntry">
>>>>
>>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>>
>>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>>
>>>> </xsd:complexType>
>>>>
>>>> But my XML editor complains
>>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>>> unresolved
>>>>
>>>> I added this at the beginning of the xsd file:
>>>>
>>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>>
>>>> What else am I missing?
>>>>
>>>> Thanks,
>>>>
>>>> David
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>


--------------070407030405090906020207
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">
David,<br>
<br>
You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API. <br>
<br>
For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value".&nbsp; For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map".&nbsp; Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.<br>
<br>
Hopefully I've correctly understood that you want a map that maps a
string to another map....<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vlpe$jkg$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I reloaded the xml file in the
editor and it worked!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I agree to use java.util.Map,
but when I generate the model, it creates an EMap... I use the
following type:</font></div>
<div>&nbsp;</div>
<div><font size="2">
<p align="left">&lt;xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;xsd:attribute name="key" type="xsd:string"/&gt;</p>
<p align="left">&lt;xsd:attribute name="value" type="xsd:anyType"/&gt;</p>
<p>&lt;/xsd:complexType&gt;</p>
<p><font face="Arial">with </font></p>
<font size="2">
<p align="left">&lt;xsd:element maxOccurs="unbounded" name="DataSets"
type="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;/xsd:element&gt;</p>
<p align="left">How can I force it to generate a java.util.Map
instead?</p>
<p align="left"><font face="Arial">I'm still not clear how to
register the EDataType, where should it go in the schema?</font></p>
<p align="left"><font face="Arial">Thanks,</font></p>
<p align="left"><font face="Arial">David</font></p>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext"
href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------070407030405090906020207--
Re: ecore namespace? [message #401018 is a reply to message #401017] Thu, 11 May 2006 12:00 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_19D1_01C67524.CA382F30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Sorry I think I confused you with one of my older posts (which was =
incorrect), in fact I just need a map of string/object. Not a map of =
maps...

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vmqv$ore$1@utils.eclipse.org...
David,

You need to set the GenModel property "Suppress EMF Types" to true for =
an EMap to be surfaced as a java.util.Map view of the EMap in the =
generated API.=20

For the "value"'s type, you should define a new simpleType =
"DataSetMap" that restricts "base64Binary" and make that the type of =
"value". For that new simple type, you should set the =
ecore:instanceClassName to "java.util.Map". Then, in the generated =
XyzFactoryImpl you'll need to implement the create/convert methods as I =
outline earlier.

Hopefully I've correctly understood that you want a map that maps a =
string to another map....


David Michonneau wrote:=20
I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate the model, it =
creates an EMap... I use the following type:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where should it =
go in the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to use schema =
types (xsd:string) and for EMap you'll need to define your own type =
anyway. If you take the approach I outlined of serializing the value =
map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20



------=_NextPart_000_19D1_01C67524.CA382F30
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Sorry I think I confused you with one =
of my older=20
posts (which was incorrect), in fact I just need a map of string/object. =
Not a=20
map of maps...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
need to set the GenModel property "Suppress EMF Types" to true for an =
EMap to=20
be surfaced as a java.util.Map view of the EMap in the generated API.=20
<BR><BR>For the "value"'s type, you should define a new simpleType=20
"DataSetMap" that restricts "base64Binary" and make that the type of=20
"value".&nbsp; For that new simple type, you should set the=20
ecore:instanceClassName to "java.util.Map".&nbsp; Then, in the =
generated=20
XyzFactoryImpl you'll need to implement the create/convert methods as =
I=20
outline earlier.<BR><BR>Hopefully I've correctly understood that you =
want a=20
map that maps a string to another map....<BR><BR><BR>David Michonneau =
wrote:=20
<BLOCKQUOTE cite=3Dmide3vlpe$jkg$1@utils.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I reloaded the xml file in the =
editor and it=20
worked!</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use java.util.Map, =
but when I=20
generate the model, it creates an EMap... I use the following=20
type:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType =
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key" =
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value" =
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded" =
name=3D"DataSets"=20
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a java.util.Map =
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear how to =
register the=20
EDataType, where should it go in the schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT =
face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better to use schema =
types=20
(xsd:string) and for EMap you'll need to define your own type=20
anyway.&nbsp; If you take the approach I outlined of serializing =
the value=20
map as a base64 "blob", I'd define a new data type that restricts=20
base64Binary and defines the ecore:instanceClass to be=20
java.util.Map.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BODY>=
</HTML>

------=_NextPart_000_19D1_01C67524.CA382F30--
Re: ecore namespace? [message #401019 is a reply to message #401018] Thu, 11 May 2006 12:02 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------040202040609040909060006
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

I had a feeling about that. ;-)

The same type of approach will apply, but the new data type you
introduce will just specify java.lang.Object as the instanceClassName.



David Michonneau wrote:
> Sorry I think I confused you with one of my older posts (which was
> incorrect), in fact I just need a map of string/object. Not a map of
> maps...
>
> Thanks,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:e3vmqv$ore$1@utils.eclipse.org...
> David,
>
> You need to set the GenModel property "Suppress EMF Types" to true
> for an EMap to be surfaced as a java.util.Map view of the EMap in
> the generated API.
>
> For the "value"'s type, you should define a new simpleType
> "DataSetMap" that restricts "base64Binary" and make that the type
> of "value". For that new simple type, you should set the
> ecore:instanceClassName to "java.util.Map". Then, in the
> generated XyzFactoryImpl you'll need to implement the
> create/convert methods as I outline earlier.
>
> Hopefully I've correctly understood that you want a map that maps
> a string to another map....
>
>
> David Michonneau wrote:
>> I reloaded the xml file in the editor and it worked!
>>
>> Now I agree to use java.util.Map, but when I generate the model,
>> it creates an EMap... I use the following type:
>>
>>
>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>> name="EStringToDataSetMapEntry">
>>
>> <xsd:attribute name="key" type="xsd:string"/>
>>
>> <xsd:attribute name="value" type="xsd:anyType"/>
>>
>> </xsd:complexType>
>>
>> with
>>
>> <xsd:element maxOccurs="unbounded" name="DataSets"
>> type="EStringToDataSetMapEntry">
>>
>> </xsd:element>
>>
>> How can I force it to generate a java.util.Map instead?
>>
>> I'm still not clear how to register the EDataType, where should
>> it go in the schema?
>>
>> Thanks,
>>
>> David
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:e3vj4q$47o$1@utils.eclipse.org...
>> David,
>>
>> Are you using EMF 2.2? I think you would be better to use
>> schema types (xsd:string) and for EMap you'll need to define
>> your own type anyway. If you take the approach I outlined of
>> serializing the value map as a base64 "blob", I'd define a
>> new data type that restricts base64Binary and defines the
>> ecore:instanceClass to be java.util.Map.
>>
>>
>> David Michonneau wrote:
>>> Hi,
>>>
>>> I did add this line, but it still complains, and the generator too:
>>>
>>> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
>>> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>>>
>>> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>> news:e3vgh6$p18$1@utils.eclipse.org...
>>>
>>>> David,
>>>>
>>>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>>>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>>>> the schemaLocation to do that.
>>>>
>>>> Why not use xsd:string? Are you sure you want the itself value to be an
>>>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>>>
>>>> David Michonneau wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to add this type in my schema file:
>>>>>
>>>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>>>> name="EStringToDataSetMapEntry">
>>>>>
>>>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>>>
>>>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>>>
>>>>> </xsd:complexType>
>>>>>
>>>>> But my XML editor complains
>>>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>>>> unresolved
>>>>>
>>>>> I added this at the beginning of the xsd file:
>>>>>
>>>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>>>
>>>>> What else am I missing?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>
>


--------------040202040609040909060006
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">
David,<br>
<br>
I had a feeling about that. ;-)<br>
<br>
The same type of approach will apply, but the new data type you
introduce will just specify java.lang.Object as the instanceClassName.<br>
<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vn2t$q18$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">Sorry I think I confused you with
one of my older posts (which was incorrect), in fact I just need a map
of string/object. Not a map of maps...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API. <br>
<br>
For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value".&nbsp; For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map".&nbsp; Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.<br>
<br>
Hopefully I've correctly understood that you want a map that maps a
string to another map....<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vlpe$jkg$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I reloaded the xml file in the
editor and it worked!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I agree to use
java.util.Map, but when I generate the model, it creates an EMap... I
use the following type:</font></div>
<div>&nbsp;</div>
<div><font size="2">
<p align="left">&lt;xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;xsd:attribute name="key"
type="xsd:string"/&gt;</p>
<p align="left">&lt;xsd:attribute name="value"
type="xsd:anyType"/&gt;</p>
<p>&lt;/xsd:complexType&gt;</p>
<p><font face="Arial">with </font></p>
<font size="2">
<p align="left">&lt;xsd:element maxOccurs="unbounded"
name="DataSets" type="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;/xsd:element&gt;</p>
<p align="left">How can I force it to generate a java.util.Map
instead?</p>
<p align="left"><font face="Arial">I'm still not clear how to
register the EDataType, where should it go in the schema?</font></p>
<p align="left"><font face="Arial">Thanks,</font></p>
<p align="left"><font face="Arial">David</font></p>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext"
href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------040202040609040909060006--
Re: ecore namespace? [message #401029 is a reply to message #401017] Thu, 11 May 2006 13:11 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_19EA_01C6752E.C07CFD40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

When I set that "suppress" property, all my EMF types will revert to =
java types. But I can't afford this change now, it will break the =
backward compatibility of my model. Is there a way to only apply it to =
this EMap?=20

Or can I extend EMap to enable its serialization and use this extended =
type somehow?

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vmqv$ore$1@utils.eclipse.org...
David,

You need to set the GenModel property "Suppress EMF Types" to true for =
an EMap to be surfaced as a java.util.Map view of the EMap in the =
generated API.=20

For the "value"'s type, you should define a new simpleType =
"DataSetMap" that restricts "base64Binary" and make that the type of =
"value". For that new simple type, you should set the =
ecore:instanceClassName to "java.util.Map". Then, in the generated =
XyzFactoryImpl you'll need to implement the create/convert methods as I =
outline earlier.

Hopefully I've correctly understood that you want a map that maps a =
string to another map....


David Michonneau wrote:=20
I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate the model, it =
creates an EMap... I use the following type:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where should it =
go in the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to use schema =
types (xsd:string) and for EMap you'll need to define your own type =
anyway. If you take the approach I outlined of serializing the value =
map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20



------=_NextPart_000_19EA_01C6752E.C07CFD40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>When I set that "suppress" property, =
all my EMF=20
types will revert to java types. But I can't afford this change now, it =
will=20
break the backward compatibility of my model. Is there a way to only =
apply it to=20
this EMap? </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Or can I extend&nbsp;EMap to enable its =

serialization and use this extended type somehow?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
need to set the GenModel property "Suppress EMF Types" to true for an =
EMap to=20
be surfaced as a java.util.Map view of the EMap in the generated API.=20
<BR><BR>For the "value"'s type, you should define a new simpleType=20
"DataSetMap" that restricts "base64Binary" and make that the type of=20
"value".&nbsp; For that new simple type, you should set the=20
ecore:instanceClassName to "java.util.Map".&nbsp; Then, in the =
generated=20
XyzFactoryImpl you'll need to implement the create/convert methods as =
I=20
outline earlier.<BR><BR>Hopefully I've correctly understood that you =
want a=20
map that maps a string to another map....<BR><BR><BR>David Michonneau =
wrote:=20
<BLOCKQUOTE cite=3Dmide3vlpe$jkg$1@utils.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I reloaded the xml file in the =
editor and it=20
worked!</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use java.util.Map, =
but when I=20
generate the model, it creates an EMap... I use the following=20
type:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType =
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key" =
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value" =
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded" =
name=3D"DataSets"=20
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a java.util.Map =
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear how to =
register the=20
EDataType, where should it go in the schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT =
face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better to use schema =
types=20
(xsd:string) and for EMap you'll need to define your own type=20
anyway.&nbsp; If you take the approach I outlined of serializing =
the value=20
map as a base64 "blob", I'd define a new data type that restricts=20
base64Binary and defines the ecore:instanceClass to be=20
java.util.Map.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BODY>=
</HTML>

------=_NextPart_000_19EA_01C6752E.C07CFD40--
Re: ecore namespace? [message #401031 is a reply to message #401029] Thu, 11 May 2006 13:15 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------080009020200030009030604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

You could use ecore:suppressedGetVisibility="true" (assuming you are
using EMF 2.2) to not have the EMap method in the API. And then you
could add your own method by hand, and use EMap.map() to return a view
on the EMap. (That's such suppressing the EMF types does.)


David Michonneau wrote:
> When I set that "suppress" property, all my EMF types will revert to
> java types. But I can't afford this change now, it will break the
> backward compatibility of my model. Is there a way to only apply it to
> this EMap?
>
> Or can I extend EMap to enable its serialization and use this extended
> type somehow?
>
> Thanks,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:e3vmqv$ore$1@utils.eclipse.org...
> David,
>
> You need to set the GenModel property "Suppress EMF Types" to true
> for an EMap to be surfaced as a java.util.Map view of the EMap in
> the generated API.
>
> For the "value"'s type, you should define a new simpleType
> "DataSetMap" that restricts "base64Binary" and make that the type
> of "value". For that new simple type, you should set the
> ecore:instanceClassName to "java.util.Map". Then, in the
> generated XyzFactoryImpl you'll need to implement the
> create/convert methods as I outline earlier.
>
> Hopefully I've correctly understood that you want a map that maps
> a string to another map....
>
>
> David Michonneau wrote:
>> I reloaded the xml file in the editor and it worked!
>>
>> Now I agree to use java.util.Map, but when I generate the model,
>> it creates an EMap... I use the following type:
>>
>>
>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>> name="EStringToDataSetMapEntry">
>>
>> <xsd:attribute name="key" type="xsd:string"/>
>>
>> <xsd:attribute name="value" type="xsd:anyType"/>
>>
>> </xsd:complexType>
>>
>> with
>>
>> <xsd:element maxOccurs="unbounded" name="DataSets"
>> type="EStringToDataSetMapEntry">
>>
>> </xsd:element>
>>
>> How can I force it to generate a java.util.Map instead?
>>
>> I'm still not clear how to register the EDataType, where should
>> it go in the schema?
>>
>> Thanks,
>>
>> David
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:e3vj4q$47o$1@utils.eclipse.org...
>> David,
>>
>> Are you using EMF 2.2? I think you would be better to use
>> schema types (xsd:string) and for EMap you'll need to define
>> your own type anyway. If you take the approach I outlined of
>> serializing the value map as a base64 "blob", I'd define a
>> new data type that restricts base64Binary and defines the
>> ecore:instanceClass to be java.util.Map.
>>
>>
>> David Michonneau wrote:
>>> Hi,
>>>
>>> I did add this line, but it still complains, and the generator too:
>>>
>>> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
>>> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>>>
>>> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>> news:e3vgh6$p18$1@utils.eclipse.org...
>>>
>>>> David,
>>>>
>>>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>>>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>>>> the schemaLocation to do that.
>>>>
>>>> Why not use xsd:string? Are you sure you want the itself value to be an
>>>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>>>
>>>> David Michonneau wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to add this type in my schema file:
>>>>>
>>>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>>>> name="EStringToDataSetMapEntry">
>>>>>
>>>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>>>
>>>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>>>
>>>>> </xsd:complexType>
>>>>>
>>>>> But my XML editor complains
>>>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>>>> unresolved
>>>>>
>>>>> I added this at the beginning of the xsd file:
>>>>>
>>>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>>>
>>>>> What else am I missing?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>
>


--------------080009020200030009030604
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">
David,<br>
<br>
You could use ecore:suppressedGetVisibility="true" (assuming you are
using EMF 2.2) to not have the EMap method in the API.&nbsp; And then you
could add your own method by hand, and use EMap.map() to return a view
on the EMap.&nbsp; (That's such suppressing the EMF types does.)<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vr8j$82v$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">When I set that "suppress" property,
all my EMF types will revert to java types. But I can't afford this
change now, it will break the backward compatibility of my model. Is
there a way to only apply it to this EMap? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Or can I extend&nbsp;EMap to enable its
serialization and use this extended type somehow?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API. <br>
<br>
For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value".&nbsp; For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map".&nbsp; Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.<br>
<br>
Hopefully I've correctly understood that you want a map that maps a
string to another map....<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vlpe$jkg$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I reloaded the xml file in the
editor and it worked!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I agree to use
java.util.Map, but when I generate the model, it creates an EMap... I
use the following type:</font></div>
<div>&nbsp;</div>
<div><font size="2">
<p align="left">&lt;xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;xsd:attribute name="key"
type="xsd:string"/&gt;</p>
<p align="left">&lt;xsd:attribute name="value"
type="xsd:anyType"/&gt;</p>
<p>&lt;/xsd:complexType&gt;</p>
<p><font face="Arial">with </font></p>
<font size="2">
<p align="left">&lt;xsd:element maxOccurs="unbounded"
name="DataSets" type="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;/xsd:element&gt;</p>
<p align="left">How can I force it to generate a java.util.Map
instead?</p>
<p align="left"><font face="Arial">I'm still not clear how to
register the EDataType, where should it go in the schema?</font></p>
<p align="left"><font face="Arial">Thanks,</font></p>
<p align="left"><font face="Arial">David</font></p>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext"
href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------080009020200030009030604--
Re: ecore namespace? [message #401034 is a reply to message #401031] Thu, 11 May 2006 13:37 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_1A13_01C67532.4F6C73C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Ed,

Sorry, but I think I got confused. If it only suppress the API =
visibility, it's doesn't matter to me to expose an EMap, I just want it =
to be serialized.

So here is my problem again:

I have an EMap of String/Objects. I understand the bit about serializing =
the Object. Do I need to do anything for the EMap? Should I set its =
containment to true or something like that?

Thanks for your patience,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vrfk$89f$2@utils.eclipse.org...
David,

You could use ecore:suppressedGetVisibility=3D"true" (assuming you are =
using EMF 2.2) to not have the EMap method in the API. And then you =
could add your own method by hand, and use EMap.map() to return a view =
on the EMap. (That's such suppressing the EMF types does.)


David Michonneau wrote:=20
When I set that "suppress" property, all my EMF types will revert to =
java types. But I can't afford this change now, it will break the =
backward compatibility of my model. Is there a way to only apply it to =
this EMap?=20

Or can I extend EMap to enable its serialization and use this =
extended type somehow?

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vmqv$ore$1@utils.eclipse.org...
David,

You need to set the GenModel property "Suppress EMF Types" to true =
for an EMap to be surfaced as a java.util.Map view of the EMap in the =
generated API.=20

For the "value"'s type, you should define a new simpleType =
"DataSetMap" that restricts "base64Binary" and make that the type of =
"value". For that new simple type, you should set the =
ecore:instanceClassName to "java.util.Map". Then, in the generated =
XyzFactoryImpl you'll need to implement the create/convert methods as I =
outline earlier.

Hopefully I've correctly understood that you want a map that maps =
a string to another map....


David Michonneau wrote:=20
I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate the model, =
it creates an EMap... I use the following type:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where should =
it go in the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to use =
schema types (xsd:string) and for EMap you'll need to define your own =
type anyway. If you take the approach I outlined of serializing the =
value map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20





------=_NextPart_000_1A13_01C67532.4F6C73C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry, but I think I got confused. If =
it only=20
suppress the API visibility, it's doesn't matter to me to expose an =
EMap, I just=20
want it to be serialized.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So here is my problem =
again:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have an EMap of String/Objects. I =
understand the=20
bit about serializing the Object. Do I need to do anything for the EMap? =
Should=20
I set its containment to true or something like that?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your patience,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
could use ecore:suppressedGetVisibility=3D"true" (assuming you are =
using EMF=20
2.2) to not have the EMap method in the API.&nbsp; And then you could =
add your=20
own method by hand, and use EMap.map() to return a view on the =
EMap.&nbsp;=20
(That's such suppressing the EMF types does.)<BR><BR><BR>David =
Michonneau=20
wrote:=20
<BLOCKQUOTE cite=3Dmide3vr8j$82v$1@utils.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>When I set that "suppress" =
property, all my EMF=20
types will revert to java types. But I can't afford this change now, =
it will=20
break the backward compatibility of my model. Is there a way to only =
apply=20
it to this EMap? </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Or can I extend&nbsp;EMap to enable =
its=20
serialization and use this extended type somehow?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
need to set the GenModel property "Suppress EMF Types" to true for =
an EMap=20
to be surfaced as a java.util.Map view of the EMap in the =
generated API.=20
<BR><BR>For the "value"'s type, you should define a new simpleType =

"DataSetMap" that restricts "base64Binary" and make that the type =
of=20
"value".&nbsp; For that new simple type, you should set the=20
ecore:instanceClassName to "java.util.Map".&nbsp; Then, in the =
generated=20
XyzFactoryImpl you'll need to implement the create/convert methods =
as I=20
outline earlier.<BR><BR>Hopefully I've correctly understood that =
you want=20
a map that maps a string to another map....<BR><BR><BR>David =
Michonneau=20
wrote:=20
<BLOCKQUOTE cite=3Dmide3vlpe$jkg$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I reloaded the xml file in the =
editor and=20
it worked!</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use =
java.util.Map, but when=20
I generate the model, it creates an EMap... I use the following=20
type:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType=20
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key" =
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value" =
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded" =
name=3D"DataSets"=20
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a java.util.Map=20
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear how to =
register the=20
EDataType, where should it go in the schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT =
face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better to use =
schema=20
types (xsd:string) and for EMap you'll need to define your own =
type=20
anyway.&nbsp; If you take the approach I outlined of =
serializing the=20
value map as a base64 "blob", I'd define a new data type that=20
restricts base64Binary and defines the ecore:instanceClass to =
be=20
java.util.Map.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BLOCK=
QUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_1A13_01C67532.4F6C73C0--
Re: ecore namespace? [message #401038 is a reply to message #401034] Thu, 11 May 2006 13:45 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------070701000406070506020901
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

It should serialize fine. The feature corresponding to the "DataSets"
element should already be marked as a containment. I think all you have
left to do is make sure the "value" feature serializes.


David Michonneau wrote:
> Hi Ed,
>
> Sorry, but I think I got confused. If it only suppress the API
> visibility, it's doesn't matter to me to expose an EMap, I just want
> it to be serialized.
>
> So here is my problem again:
>
> I have an EMap of String/Objects. I understand the bit about
> serializing the Object. Do I need to do anything for the EMap? Should
> I set its containment to true or something like that?
>
> Thanks for your patience,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:e3vrfk$89f$2@utils.eclipse.org...
> David,
>
> You could use ecore:suppressedGetVisibility="true" (assuming you
> are using EMF 2.2) to not have the EMap method in the API. And
> then you could add your own method by hand, and use EMap.map() to
> return a view on the EMap. (That's such suppressing the EMF types
> does.)
>
>
> David Michonneau wrote:
>> When I set that "suppress" property, all my EMF types will revert
>> to java types. But I can't afford this change now, it will break
>> the backward compatibility of my model. Is there a way to only
>> apply it to this EMap?
>>
>> Or can I extend EMap to enable its serialization and use this
>> extended type somehow?
>>
>> Thanks,
>>
>> David
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:e3vmqv$ore$1@utils.eclipse.org...
>> David,
>>
>> You need to set the GenModel property "Suppress EMF Types" to
>> true for an EMap to be surfaced as a java.util.Map view of
>> the EMap in the generated API.
>>
>> For the "value"'s type, you should define a new simpleType
>> "DataSetMap" that restricts "base64Binary" and make that the
>> type of "value". For that new simple type, you should set
>> the ecore:instanceClassName to "java.util.Map". Then, in the
>> generated XyzFactoryImpl you'll need to implement the
>> create/convert methods as I outline earlier.
>>
>> Hopefully I've correctly understood that you want a map that
>> maps a string to another map....
>>
>>
>> David Michonneau wrote:
>>> I reloaded the xml file in the editor and it worked!
>>>
>>> Now I agree to use java.util.Map, but when I generate the
>>> model, it creates an EMap... I use the following type:
>>>
>>>
>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>> name="EStringToDataSetMapEntry">
>>>
>>> <xsd:attribute name="key" type="xsd:string"/>
>>>
>>> <xsd:attribute name="value" type="xsd:anyType"/>
>>>
>>> </xsd:complexType>
>>>
>>> with
>>>
>>> <xsd:element maxOccurs="unbounded" name="DataSets"
>>> type="EStringToDataSetMapEntry">
>>>
>>> </xsd:element>
>>>
>>> How can I force it to generate a java.util.Map instead?
>>>
>>> I'm still not clear how to register the EDataType, where
>>> should it go in the schema?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>>
>>> wrote in message news:e3vj4q$47o$1@utils.eclipse.org...
>>> David,
>>>
>>> Are you using EMF 2.2? I think you would be better to
>>> use schema types (xsd:string) and for EMap you'll need
>>> to define your own type anyway. If you take the
>>> approach I outlined of serializing the value map as a
>>> base64 "blob", I'd define a new data type that restricts
>>> base64Binary and defines the ecore:instanceClass to be
>>> java.util.Map.
>>>
>>>
>>> David Michonneau wrote:
>>>> Hi,
>>>>
>>>> I did add this line, but it still complains, and the generator too:
>>>>
>>>> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
>>>> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>>>>
>>>> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>>>>
>>>> Thanks,
>>>>
>>>> David
>>>>
>>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>>> news:e3vgh6$p18$1@utils.eclipse.org...
>>>>
>>>>> David,
>>>>>
>>>>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>>>>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>>>>> the schemaLocation to do that.
>>>>>
>>>>> Why not use xsd:string? Are you sure you want the itself value to be an
>>>>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>>>>
>>>>> David Michonneau wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to add this type in my schema file:
>>>>>>
>>>>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>>>>> name="EStringToDataSetMapEntry">
>>>>>>
>>>>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>>>>
>>>>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>>>>
>>>>>> </xsd:complexType>
>>>>>>
>>>>>> But my XML editor complains
>>>>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>>>>> unresolved
>>>>>>
>>>>>> I added this at the beginning of the xsd file:
>>>>>>
>>>>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>>>>
>>>>>> What else am I missing?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>
>>
>


--------------070701000406070506020901
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">
David,<br>
<br>
It should serialize fine.&nbsp; The feature corresponding to the "<font><font><font
size="2"><font size="2">DataSets" element </font></font></font></font>should
already be marked as a containment.&nbsp; I think all you have left to do is
make sure the "value" feature serializes.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vsoc$h2o$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">Hi Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Sorry, but I think I got confused.
If it only suppress the API visibility, it's doesn't matter to me to
expose an EMap, I just want it to be serialized.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">So here is my problem again:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I have an EMap of String/Objects. I
understand the bit about serializing the Object. Do I need to do
anything for the EMap? Should I set its containment to true or
something like that?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks for your patience,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.eclipse.org</a>...</div>
David,<br>
<br>
You could use ecore:suppressedGetVisibility="true" (assuming you are
using EMF 2.2) to not have the EMap method in the API.&nbsp; And then you
could add your own method by hand, and use EMap.map() to return a view
on the EMap.&nbsp; (That's such suppressing the EMF types does.)<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vr8j$82v$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">When I set that "suppress"
property, all my EMF types will revert to java types. But I can't
afford this change now, it will break the backward compatibility of my
model. Is there a way to only apply it to this EMap? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Or can I extend&nbsp;EMap to enable
its serialization and use this extended type somehow?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API. <br>
<br>
For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value".&nbsp; For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map".&nbsp; Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.<br>
<br>
Hopefully I've correctly understood that you want a map that maps a
string to another map....<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vlpe$jkg$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I reloaded the xml file in
the editor and it worked!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I agree to use
java.util.Map, but when I generate the model, it creates an EMap... I
use the following type:</font></div>
<div>&nbsp;</div>
<div><font size="2">
<p align="left">&lt;xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;xsd:attribute name="key"
type="xsd:string"/&gt;</p>
<p align="left">&lt;xsd:attribute name="value"
type="xsd:anyType"/&gt;</p>
<p>&lt;/xsd:complexType&gt;</p>
<p><font face="Arial">with </font></p>
<font size="2">
<p align="left">&lt;xsd:element maxOccurs="unbounded"
name="DataSets" type="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;/xsd:element&gt;</p>
<p align="left">How can I force it to generate a
java.util.Map instead?</p>
<p align="left"><font face="Arial">I'm still not clear how to
register the EDataType, where should it go in the schema?</font></p>
<p align="left"><font face="Arial">Thanks,</font></p>
<p align="left"><font face="Arial">David</font></p>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org"
type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext"
href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------070701000406070506020901--
Re: ecore namespace? [message #401043 is a reply to message #401038] Thu, 11 May 2006 16:05 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_1A65_01C67546.F8E38A60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Ed,

Thank you for your help so far! I am almost there. I did exactly as you =
suggested, but I have one more problem:

Sometimes the Object to serialize is an EObject (one of my EMF objects =
of my model). Unfortunately they are not serializable. Is there an easy =
way to mark them as Serializable or to serialize them?=20

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vt7o$kag$1@utils.eclipse.org...
David,

It should serialize fine. The feature corresponding to the "DataSets" =
element should already be marked as a containment. I think all you have =
left to do is make sure the "value" feature serializes.


David Michonneau wrote:=20
Hi Ed,

Sorry, but I think I got confused. If it only suppress the API =
visibility, it's doesn't matter to me to expose an EMap, I just want it =
to be serialized.

So here is my problem again:

I have an EMap of String/Objects. I understand the bit about =
serializing the Object. Do I need to do anything for the EMap? Should I =
set its containment to true or something like that?

Thanks for your patience,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vrfk$89f$2@utils.eclipse.org...
David,

You could use ecore:suppressedGetVisibility=3D"true" (assuming you =
are using EMF 2.2) to not have the EMap method in the API. And then you =
could add your own method by hand, and use EMap.map() to return a view =
on the EMap. (That's such suppressing the EMF types does.)


David Michonneau wrote:=20
When I set that "suppress" property, all my EMF types will =
revert to java types. But I can't afford this change now, it will break =
the backward compatibility of my model. Is there a way to only apply it =
to this EMap?=20

Or can I extend EMap to enable its serialization and use this =
extended type somehow?

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vmqv$ore$1@utils.eclipse.org...
David,

You need to set the GenModel property "Suppress EMF Types" to =
true for an EMap to be surfaced as a java.util.Map view of the EMap in =
the generated API.=20

For the "value"'s type, you should define a new simpleType =
"DataSetMap" that restricts "base64Binary" and make that the type of =
"value". For that new simple type, you should set the =
ecore:instanceClassName to "java.util.Map". Then, in the generated =
XyzFactoryImpl you'll need to implement the create/convert methods as I =
outline earlier.

Hopefully I've correctly understood that you want a map that =
maps a string to another map....


David Michonneau wrote:=20
I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate the =
model, it creates an EMap... I use the following type:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where =
should it go in the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to use =
schema types (xsd:string) and for EMap you'll need to define your own =
type anyway. If you take the approach I outlined of serializing the =
value map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20







------=_NextPart_000_1A65_01C67546.F8E38A60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you for your help so far! I am =
almost there.=20
I did exactly as you suggested, but I have one more =
problem:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sometimes the Object to serialize is an =
EObject=20
(one of my EMF objects of my model). Unfortunately they are not =
serializable. Is=20
there an easy way to mark them as Serializable or to serialize them?=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e3vt7o$kag$1@utils.eclipse.org">news:e3vt7o$kag$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>It=20
should serialize fine.&nbsp; The feature corresponding to the "<FONT=20
size=3D+0><FONT size=3D+0><FONT size=3D2><FONT size=3D2>DataSets" =
element=20
</FONT></FONT></FONT></FONT>should already be marked as a =
containment.&nbsp; I=20
think all you have left to do is make sure the "value" feature=20
serializes.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vsoc$h2o$1@utils.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry, but I think I got confused. =
If it only=20
suppress the API visibility, it's doesn't matter to me to expose an =
EMap, I=20
just want it to be serialized.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So here is my problem =
again:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have an EMap of String/Objects. I =
understand=20
the bit about serializing the Object. Do I need to do anything for =
the EMap?=20
Should I set its containment to true or something like =
that?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your =
patience,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
could use ecore:suppressedGetVisibility=3D"true" (assuming you are =
using EMF=20
2.2) to not have the EMap method in the API.&nbsp; And then you =
could add=20
your own method by hand, and use EMap.map() to return a view on =
the=20
EMap.&nbsp; (That's such suppressing the EMF types =
does.)<BR><BR><BR>David=20
Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vr8j$82v$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>When I set that "suppress" =
property, all my=20
EMF types will revert to java types. But I can't afford this =
change now,=20
it will break the backward compatibility of my model. Is there a =
way to=20
only apply it to this EMap? </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Or can I extend&nbsp;EMap to =
enable its=20
serialization and use this extended type somehow?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
need to set the GenModel property "Suppress EMF Types" to true =
for an=20
EMap to be surfaced as a java.util.Map view of the EMap in the =

generated API. <BR><BR>For the "value"'s type, you should =
define a new=20
simpleType "DataSetMap" that restricts "base64Binary" and make =
that=20
the type of "value".&nbsp; For that new simple type, you =
should set=20
the ecore:instanceClassName to "java.util.Map".&nbsp; Then, in =
the=20
generated XyzFactoryImpl you'll need to implement the =
create/convert=20
methods as I outline earlier.<BR><BR>Hopefully I've correctly=20
understood that you want a map that maps a string to another=20
map....<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vlpe$jkg$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I reloaded the xml file in =
the editor=20
and it worked!</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use =
java.util.Map, but=20
when I generate the model, it creates an EMap... I use the =
following=20
type:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType=20
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key"=20
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value"=20
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded" =
name=3D"DataSets"=20
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a =
java.util.Map=20
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear how =
to register=20
the EDataType, where should it go in the schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT =
face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better to =
use schema=20
types (xsd:string) and for EMap you'll need to define your =
own=20
type anyway.&nbsp; If you take the approach I outlined of=20
serializing the value map as a base64 "blob", I'd define a =
new=20
data type that restricts base64Binary and defines the=20
ecore:instanceClass to be java.util.Map.<BR><BR><BR>David=20
Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BLOCK=
QUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY ></HTML>

------=_NextPart_000_1A65_01C67546.F8E38A60--
Re: ecore namespace? [message #401044 is a reply to message #401043] Thu, 11 May 2006 16:17 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_2042_01C67548.B4059E40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Here is how my code looks like now, it doesn't work if instanceValue is =
an EObject, because it's not marked Serializable.

Thanks,

David

public String convertDataValueToString( EDataType eDataType,
Object instanceValue )
{

ByteArrayOutputStream byteOutput =3D new ByteArrayOutputStream( );
try
{
ObjectOutputStream stream =3D new ObjectOutputStream( byteOutput =
);
stream.writeObject( instanceValue );
}
catch ( IOException e )
{
e.printStackTrace();
}
return XMLTypeFactory.eINSTANCE.convertBase64Binary( =
byteOutput.toByteArray( ) );

}
"David Michonneau" <dmichonneau@actuate.com> wrote in message =
news:e405dm$ru7$1@utils.eclipse.org...
Hi Ed,

Thank you for your help so far! I am almost there. I did exactly as =
you suggested, but I have one more problem:

Sometimes the Object to serialize is an EObject (one of my EMF objects =
of my model). Unfortunately they are not serializable. Is there an easy =
way to mark them as Serializable or to serialize them?=20

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vt7o$kag$1@utils.eclipse.org...
David,

It should serialize fine. The feature corresponding to the =
"DataSets" element should already be marked as a containment. I think =
all you have left to do is make sure the "value" feature serializes.


David Michonneau wrote:=20
Hi Ed,

Sorry, but I think I got confused. If it only suppress the API =
visibility, it's doesn't matter to me to expose an EMap, I just want it =
to be serialized.

So here is my problem again:

I have an EMap of String/Objects. I understand the bit about =
serializing the Object. Do I need to do anything for the EMap? Should I =
set its containment to true or something like that?

Thanks for your patience,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vrfk$89f$2@utils.eclipse.org...
David,

You could use ecore:suppressedGetVisibility=3D"true" (assuming =
you are using EMF 2.2) to not have the EMap method in the API. And then =
you could add your own method by hand, and use EMap.map() to return a =
view on the EMap. (That's such suppressing the EMF types does.)


David Michonneau wrote:=20
When I set that "suppress" property, all my EMF types will =
revert to java types. But I can't afford this change now, it will break =
the backward compatibility of my model. Is there a way to only apply it =
to this EMap?=20

Or can I extend EMap to enable its serialization and use this =
extended type somehow?

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vmqv$ore$1@utils.eclipse.org...
David,

You need to set the GenModel property "Suppress EMF Types" =
to true for an EMap to be surfaced as a java.util.Map view of the EMap =
in the generated API.=20

For the "value"'s type, you should define a new simpleType =
"DataSetMap" that restricts "base64Binary" and make that the type of =
"value". For that new simple type, you should set the =
ecore:instanceClassName to "java.util.Map". Then, in the generated =
XyzFactoryImpl you'll need to implement the create/convert methods as I =
outline earlier.

Hopefully I've correctly understood that you want a map that =
maps a string to another map....


David Michonneau wrote:=20
I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate the =
model, it creates an EMap... I use the following type:

<xsd:complexType =
ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where =
should it go in the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to =
use schema types (xsd:string) and for EMap you'll need to define your =
own type anyway. If you take the approach I outlined of serializing the =
value map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20







------=_NextPart_000_2042_01C67548.B4059E40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Here is how my code looks like now, it =
doesn't=20
work&nbsp;if instanceValue is an&nbsp;EObject, because it's not marked=20
Serializable.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><FONT size=3D2>
<DIV align=3Dleft></FONT><B><FONT color=3D#7f0055 size=3D2><FONT=20
face=3DArial>public</FONT></B></FONT><FONT size=3D2><FONT face=3DArial> =
String=20
convertDataValueToString( EDataType eDataType,</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>Object instanceValue )</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>{</FONT></DIV>
<DIV align=3Dleft>&nbsp;</DIV>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; =
ByteArrayOutputStream=20
byteOutput =3D </FONT></FONT><B><FONT color=3D#7f0055 size=3D2><FONT=20
face=3DArial>new</FONT></B></FONT><FONT size=3D2><FONT face=3DArial>=20
ByteArrayOutputStream( );</FONT></DIV>
<DIV align=3Dleft></FONT><B><FONT color=3D#7f0055 size=3D2><FONT=20
face=3DArial>&nbsp;&nbsp;&nbsp; try</FONT></DIV></B></FONT><FONT =
size=3D2>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; {</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
ObjectOutputStream stream =3D </FONT></FONT><B><FONT color=3D#7f0055 =
size=3D2><FONT=20
face=3DArial>new</FONT></B></FONT><FONT size=3D2><FONT face=3DArial>=20
ObjectOutputStream( byteOutput );</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
stream.writeObject( instanceValue );</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV align=3Dleft></FONT><B><FONT color=3D#7f0055 size=3D2><FONT=20
face=3DArial>&nbsp;&nbsp;&nbsp; catch</FONT></B></FONT><FONT =
size=3D2><FONT=20
face=3DArial> ( IOException e )</FONT></DIV>
<DIV align=3Dleft><FONT=20
face=3DArial> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;{ </FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
e.printStackTrace();</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV align=3Dleft></FONT><B><FONT color=3D#7f0055 size=3D2><FONT=20
face=3DArial>&nbsp;&nbsp;&nbsp; return</FONT></B></FONT><FONT =
face=3DArial><FONT=20
size=3D2> XMLTypeFactory.</FONT><I><FONT color=3D#0000c0=20
size=3D2>eINSTANCE</I></FONT></FONT><FONT size=3D2><FONT=20
face=3DArial>.convertBase64Binary( byteOutput.toByteArray( ) =
);</FONT></DIV>
<DIV align=3Dleft>&nbsp;</DIV>
<DIV><FONT face=3DArial>}</FONT></DIV></FONT>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"David Michonneau" &lt;<A=20
=
href=3D"mailto:dmichonneau@actuate.com">dmichonneau@actuate.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e405dm$ru7$1@utils.eclipse.org">news:e405dm$ru7$1@utils.ecli=
pse.org</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you for your help so far! I am =
almost=20
there. I did exactly as you suggested, but I have one more=20
problem:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sometimes the Object to serialize is =
an EObject=20
(one of my EMF objects of my model). Unfortunately they are not =
serializable.=20
Is there an easy way to mark them as Serializable or to serialize =
them?=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in =
message <A=20
=
href=3D"news:e3vt7o$kag$1@utils.eclipse.org">news:e3vt7o$kag$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>It=20
should serialize fine.&nbsp; The feature corresponding to the "<FONT =

size=3D+0><FONT size=3D+0><FONT size=3D2><FONT size=3D2>DataSets" =
element=20
</FONT></FONT></FONT></FONT>should already be marked as a =
containment.&nbsp;=20
I think all you have left to do is make sure the "value" feature=20
serializes.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vsoc$h2o$1@utils.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry, but I think I got =
confused. If it only=20
suppress the API visibility, it's doesn't matter to me to expose =
an EMap,=20
I just want it to be serialized.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So here is my problem =
again:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have an EMap of String/Objects. =
I=20
understand the bit about serializing the Object. Do I need to do =
anything=20
for the EMap? Should I set its containment to true or something =
like=20
that?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your =
patience,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote =
in message=20
<A=20
=
href=3D"news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
could use ecore:suppressedGetVisibility=3D"true" (assuming you =
are using=20
EMF 2.2) to not have the EMap method in the API.&nbsp; And then =
you=20
could add your own method by hand, and use EMap.map() to return =
a view=20
on the EMap.&nbsp; (That's such suppressing the EMF types=20
does.)<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vr8j$82v$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>When I set that "suppress" =
property, all=20
my EMF types will revert to java types. But I can't afford =
this change=20
now, it will break the backward compatibility of my model. Is =
there a=20
way to only apply it to this EMap? </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Or can I extend&nbsp;EMap to =
enable its=20
serialization and use this extended type somehow?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
need to set the GenModel property "Suppress EMF Types" to =
true for=20
an EMap to be surfaced as a java.util.Map view of the EMap =
in the=20
generated API. <BR><BR>For the "value"'s type, you should =
define a=20
new simpleType "DataSetMap" that restricts "base64Binary" =
and make=20
that the type of "value".&nbsp; For that new simple type, =
you should=20
set the ecore:instanceClassName to "java.util.Map".&nbsp; =
Then, in=20
the generated XyzFactoryImpl you'll need to implement the=20
create/convert methods as I outline =
earlier.<BR><BR>Hopefully I've=20
correctly understood that you want a map that maps a string =
to=20
another map....<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vlpe$jkg$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I reloaded the xml file =
in the editor=20
and it worked!</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use =
java.util.Map, but=20
when I generate the model, it creates an EMap... I use the =

following type:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType=20
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key"=20
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value"=20
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded"=20
name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a =
java.util.Map=20
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear how =
to register=20
the EDataType, where should it go in the =
schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT=20
face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; =
MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
=
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in=20
message <A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better to =
use=20
schema types (xsd:string) and for EMap you'll need to =
define=20
your own type anyway.&nbsp; If you take the approach I =
outlined=20
of serializing the value map as a base64 "blob", I'd =
define a=20
new data type that restricts base64Binary and defines =
the=20
ecore:instanceClass to be =
java.util.Map.<BR><BR><BR>David=20
Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BLOCK=
QUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE ></BODY>=
</HTML>

------=_NextPart_000_2042_01C67548.B4059E40--
Re: ecore namespace? [message #401045 is a reply to message #401043] Thu, 11 May 2006 16:21 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------030006070908060103000009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

Making them Serializeable would be very hard. Will the EObject be
contained somewhere else or will this be the only way of reaching it?
Can it be in another resource? If it's a reference to an object
contained elsewhere you could maybe wrap it when setValue is called and
unwrap it when getValue is called, and design a Serializable wrapper
that uses EcoreUtil.getURI() to get the URI for the object and then for
unwrapping can use
ResourceSet.getResource(<uri-with-trim-fragment>).getEObject( <fragment-of-uri>)
to resolve it. If it will be in the same resource, then
resource.getFragment(EObject) and resource.getEObject(<fragment) will be
sufficient.


David Michonneau wrote:
> Hi Ed,
>
> Thank you for your help so far! I am almost there. I did exactly as
> you suggested, but I have one more problem:
>
> Sometimes the Object to serialize is an EObject (one of my EMF objects
> of my model). Unfortunately they are not serializable. Is there an
> easy way to mark them as Serializable or to serialize them?
>
> Thanks,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:e3vt7o$kag$1@utils.eclipse.org...
> David,
>
> It should serialize fine. The feature corresponding to the
> "DataSets" element should already be marked as a containment. I
> think all you have left to do is make sure the "value" feature
> serializes.
>
>
> David Michonneau wrote:
>> Hi Ed,
>>
>> Sorry, but I think I got confused. If it only suppress the API
>> visibility, it's doesn't matter to me to expose an EMap, I just
>> want it to be serialized.
>>
>> So here is my problem again:
>>
>> I have an EMap of String/Objects. I understand the bit about
>> serializing the Object. Do I need to do anything for the EMap?
>> Should I set its containment to true or something like that?
>>
>> Thanks for your patience,
>>
>> David
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:e3vrfk$89f$2@utils.eclipse.org...
>> David,
>>
>> You could use ecore:suppressedGetVisibility="true" (assuming
>> you are using EMF 2.2) to not have the EMap method in the
>> API. And then you could add your own method by hand, and use
>> EMap.map() to return a view on the EMap. (That's such
>> suppressing the EMF types does.)
>>
>>
>> David Michonneau wrote:
>>> When I set that "suppress" property, all my EMF types will
>>> revert to java types. But I can't afford this change now, it
>>> will break the backward compatibility of my model. Is there
>>> a way to only apply it to this EMap?
>>>
>>> Or can I extend EMap to enable its serialization and use
>>> this extended type somehow?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>>
>>> wrote in message news:e3vmqv$ore$1@utils.eclipse.org...
>>> David,
>>>
>>> You need to set the GenModel property "Suppress EMF
>>> Types" to true for an EMap to be surfaced as a
>>> java.util.Map view of the EMap in the generated API.
>>>
>>> For the "value"'s type, you should define a new
>>> simpleType "DataSetMap" that restricts "base64Binary"
>>> and make that the type of "value". For that new simple
>>> type, you should set the ecore:instanceClassName to
>>> "java.util.Map". Then, in the generated XyzFactoryImpl
>>> you'll need to implement the create/convert methods as I
>>> outline earlier.
>>>
>>> Hopefully I've correctly understood that you want a map
>>> that maps a string to another map....
>>>
>>>
>>> David Michonneau wrote:
>>>> I reloaded the xml file in the editor and it worked!
>>>>
>>>> Now I agree to use java.util.Map, but when I generate
>>>> the model, it creates an EMap... I use the following type:
>>>>
>>>>
>>>> <xsd:complexType
>>>> ecore:instanceClass="java.util.Map$Entry"
>>>> name="EStringToDataSetMapEntry">
>>>>
>>>> <xsd:attribute name="key" type="xsd:string"/>
>>>>
>>>> <xsd:attribute name="value" type="xsd:anyType"/>
>>>>
>>>> </xsd:complexType>
>>>>
>>>> with
>>>>
>>>> <xsd:element maxOccurs="unbounded" name="DataSets"
>>>> type="EStringToDataSetMapEntry">
>>>>
>>>> </xsd:element>
>>>>
>>>> How can I force it to generate a java.util.Map instead?
>>>>
>>>> I'm still not clear how to register the EDataType,
>>>> where should it go in the schema?
>>>>
>>>> Thanks,
>>>>
>>>> David
>>>>
>>>> "Ed Merks" <merks@ca.ibm.com
>>>> <mailto:merks@ca.ibm.com>> wrote in message
>>>> news:e3vj4q$47o$1@utils.eclipse.org...
>>>> David,
>>>>
>>>> Are you using EMF 2.2? I think you would be better
>>>> to use schema types (xsd:string) and for EMap
>>>> you'll need to define your own type anyway. If you
>>>> take the approach I outlined of serializing the
>>>> value map as a base64 "blob", I'd define a new data
>>>> type that restricts base64Binary and defines the
>>>> ecore:instanceClass to be java.util.Map.
>>>>
>>>>
>>>> David Michonneau wrote:
>>>>> Hi,
>>>>>
>>>>> I did add this line, but it still complains, and the generator too:
>>>>>
>>>>> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
>>>>> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>>>>>
>>>>> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> David
>>>>>
>>>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>>>> news:e3vgh6$p18$1@utils.eclipse.org...
>>>>>
>>>>>> David,
>>>>>>
>>>>>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>>>>>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>>>>>> the schemaLocation to do that.
>>>>>>
>>>>>> Why not use xsd:string? Are you sure you want the itself value to be an
>>>>>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>>>>>
>>>>>> David Michonneau wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am trying to add this type in my schema file:
>>>>>>>
>>>>>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>>>>>> name="EStringToDataSetMapEntry">
>>>>>>>
>>>>>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>>>>>
>>>>>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>>>>>
>>>>>>> </xsd:complexType>
>>>>>>>
>>>>>>> But my XML editor complains
>>>>>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>>>>>> unresolved
>>>>>>>
>>>>>>> I added this at the beginning of the xsd file:
>>>>>>>
>>>>>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>>>>>
>>>>>>> What else am I missing?
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


--------------030006070908060103000009
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">
David,<br>
<br>
Making them Serializeable would be very hard.&nbsp; Will the EObject be
contained somewhere else or will this be the only way of reaching it?&nbsp;
Can it be in another resource? &nbsp; If it's a reference to an object
contained elsewhere you could maybe wrap it when setValue is called and
unwrap it when getValue is called, and design a Serializable wrapper
that uses EcoreUtil.getURI() to get the URI for the object and then for
unwrapping can use
ResourceSet.getResource(&lt;uri-with-trim-fragment&g t;).getEObject(&lt;fragment-of-uri&gt;)
to resolve it.&nbsp; If it will be in the same resource, then
resource.getFragment(EObject) and resource.getEObject(&lt;fragment)
will be sufficient.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide405dm$ru7$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">Hi Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank you for your help so far! I am
almost there. I did exactly as you suggested, but I have one more
problem:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Sometimes the Object to serialize is
an EObject (one of my EMF objects of my model). Unfortunately they are
not serializable. Is there an easy way to mark them as Serializable or
to serialize them? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vt7o$kag$1@utils.eclipse.org">news:e3vt7o$kag$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
It should serialize fine.&nbsp; The feature corresponding to the "<font
size="-0"><font size="-0"><font size="2"><font size="2">DataSets"
element </font></font></font></font>should already be marked as a
containment.&nbsp; I think all you have left to do is make sure the "value"
feature serializes.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vsoc$h2o$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">Hi Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Sorry, but I think I got
confused. If it only suppress the API visibility, it's doesn't matter
to me to expose an EMap, I just want it to be serialized.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">So here is my problem again:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I have an EMap of
String/Objects. I understand the bit about serializing the Object. Do I
need to do anything for the EMap? Should I set its containment to true
or something like that?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks for your patience,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.eclipse.org</a>...</div>
David,<br>
<br>
You could use ecore:suppressedGetVisibility="true" (assuming you are
using EMF 2.2) to not have the EMap method in the API.&nbsp; And then you
could add your own method by hand, and use EMap.map() to return a view
on the EMap.&nbsp; (That's such suppressing the EMF types does.)<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vr8j$82v$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">When I set that "suppress"
property, all my EMF types will revert to java types. But I can't
afford this change now, it will break the backward compatibility of my
model. Is there a way to only apply it to this EMap? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Or can I extend&nbsp;EMap to
enable its serialization and use this extended type somehow?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API. <br>
<br>
For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value".&nbsp; For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map".&nbsp; Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.<br>
<br>
Hopefully I've correctly understood that you want a map that maps a
string to another map....<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vlpe$jkg$1@utils.eclipse.org"
type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I reloaded the xml file
in the editor and it worked!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I agree to use
java.util.Map, but when I generate the model, it creates an EMap... I
use the following type:</font></div>
<div>&nbsp;</div>
<div><font size="2">
<p align="left">&lt;xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;xsd:attribute name="key"
type="xsd:string"/&gt;</p>
<p align="left">&lt;xsd:attribute name="value"
type="xsd:anyType"/&gt;</p>
<p>&lt;/xsd:complexType&gt;</p>
<p><font face="Arial">with </font></p>
<font size="2">
<p align="left">&lt;xsd:element maxOccurs="unbounded"
name="DataSets" type="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;/xsd:element&gt;</p>
<p align="left">How can I force it to generate a
java.util.Map instead?</p>
<p align="left"><font face="Arial">I'm still not clear
how to register the EDataType, where should it go in the schema?</font></p>
<p align="left"><font face="Arial">Thanks,</font></p>
<p align="left"><font face="Arial">David</font></p>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org"
type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext"
href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------030006070908060103000009--
Re: ecore namespace? [message #401046 is a reply to message #401045] Thu, 11 May 2006 16:35 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_232C_01C6754B.250D1850
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

This seems complicated, let me give you more details:

I have this DataSet interface with setValue(Object), Object getValue().

Several interface derive from DataSet: DateTimeDataSet, NumberDataSet, =
TextDataSet,...
you can set such a specialized interface as a value in the main DataSet =
(I know it's strange, but I haven't designed it)

NumberDataSet number =3D NumberDataSetImpl.create( new double[] { 1.0, =
2.0, 3.0 } );
dataSet.setValue( numberDataSet ); // for instance
or=20
dataSet.setValue (doubleArray); // another case

so to summarize it, this EObject set as a value of my DataSet will be a =
DataSet also.

Well I am not sure that will help, but maybe I could extract the content =
in that case?=20

Anyway this EObject is not contained anywhere else. So I guess I need to =
use the resource.getFragment(EObject)? But how to access this resource? =
Then what to do in the deserialization step?

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e406co$vks$1@utils.eclipse.org...
David,

Making them Serializeable would be very hard. Will the EObject be =
contained somewhere else or will this be the only way of reaching it? =
Can it be in another resource? If it's a reference to an object =
contained elsewhere you could maybe wrap it when setValue is called and =
unwrap it when getValue is called, and design a Serializable wrapper =
that uses EcoreUtil.getURI() to get the URI for the object and then for =
unwrapping can use =
ResourceSet.getResource(<uri-with-trim-fragment>).getEObject( <fragment-of=
-uri>) to resolve it. If it will be in the same resource, then =
resource.getFragment(EObject) and resource.getEObject(<fragment) will be =
sufficient.


David Michonneau wrote:=20
Hi Ed,

Thank you for your help so far! I am almost there. I did exactly as =
you suggested, but I have one more problem:

Sometimes the Object to serialize is an EObject (one of my EMF =
objects of my model). Unfortunately they are not serializable. Is there =
an easy way to mark them as Serializable or to serialize them?=20

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vt7o$kag$1@utils.eclipse.org...
David,

It should serialize fine. The feature corresponding to the =
"DataSets" element should already be marked as a containment. I think =
all you have left to do is make sure the "value" feature serializes.


David Michonneau wrote:=20
Hi Ed,

Sorry, but I think I got confused. If it only suppress the API =
visibility, it's doesn't matter to me to expose an EMap, I just want it =
to be serialized.

So here is my problem again:

I have an EMap of String/Objects. I understand the bit about =
serializing the Object. Do I need to do anything for the EMap? Should I =
set its containment to true or something like that?

Thanks for your patience,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vrfk$89f$2@utils.eclipse.org...
David,

You could use ecore:suppressedGetVisibility=3D"true" (assuming =
you are using EMF 2.2) to not have the EMap method in the API. And then =
you could add your own method by hand, and use EMap.map() to return a =
view on the EMap. (That's such suppressing the EMF types does.)


David Michonneau wrote:=20
When I set that "suppress" property, all my EMF types will =
revert to java types. But I can't afford this change now, it will break =
the backward compatibility of my model. Is there a way to only apply it =
to this EMap?=20

Or can I extend EMap to enable its serialization and use =
this extended type somehow?

Thanks,

David
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vmqv$ore$1@utils.eclipse.org...
David,

You need to set the GenModel property "Suppress EMF Types" =
to true for an EMap to be surfaced as a java.util.Map view of the EMap =
in the generated API.=20

For the "value"'s type, you should define a new simpleType =
"DataSetMap" that restricts "base64Binary" and make that the type of =
"value". For that new simple type, you should set the =
ecore:instanceClassName to "java.util.Map". Then, in the generated =
XyzFactoryImpl you'll need to implement the create/convert methods as I =
outline earlier.

Hopefully I've correctly understood that you want a map =
that maps a string to another map....


David Michonneau wrote:=20
I reloaded the xml file in the editor and it worked!

Now I agree to use java.util.Map, but when I generate =
the model, it creates an EMap... I use the following type:

<xsd:complexType =
ecore:instanceClass=3D"java.util.Map$Entry" =
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"xsd:string"/>

<xsd:attribute name=3D"value" type=3D"xsd:anyType"/>

</xsd:complexType>

with=20

<xsd:element maxOccurs=3D"unbounded" name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry">

</xsd:element>

How can I force it to generate a java.util.Map instead?

I'm still not clear how to register the EDataType, where =
should it go in the schema?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:e3vj4q$47o$1@utils.eclipse.org...
David,

Are you using EMF 2.2? I think you would be better to =
use schema types (xsd:string) and for EMap you'll need to define your =
own type anyway. If you take the approach I outlined of serializing the =
value map as a base64 "blob", I'd define a new data type that restricts =
base64Binary and defines the ecore:instanceClass to be java.util.Map.


David Michonneau wrote:=20
Hi,

I did add this line, but it still complains, and the generator too:

<xsd:import namespace=3D"http://www.eclipse.org/emf/2002/Ecore"=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/>

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:e3vgh6$p18$1@utils.eclipse.org...
David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
Hi,

I am trying to add this type in my schema file:

<xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry">

<xsd:attribute name=3D"key" type=3D"ecore:EString"/>

<xsd:attribute name=3D"value" type=3D"ecore:EMap"/>

</xsd:complexType>

But my XML editor complains
XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is=20
unresolved

I added this at the beginning of the xsd file:

<xsd:schema xmlns:ecore=3D"http://www.eclipse.org/emf/2002/Ecore"=20
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" ...>

What else am I missing?

Thanks,

David





=20

=20









------=_NextPart_000_232C_01C6754B.250D1850
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>This seems complicated, let me give you =
more=20
details:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have this DataSet interface with=20
setValue(Object), Object getValue().</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Several interface derive from DataSet:=20
DateTimeDataSet, NumberDataSet, TextDataSet,...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>you can set such a specialized =
interface as a value=20
in the main DataSet (I know it's strange, but I haven't designed=20
it)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>NumberDataSet number =3D =
NumberDataSetImpl.create(=20
new double[] { 1.0, 2.0, 3.0 } );</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>dataSet.setValue( numberDataSet ); // =
for=20
instance</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>or </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>dataSet.setValue (doubleArray); // =
another=20
case</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>so to summarize it, this EObject set as =
a value of=20
my DataSet will be a DataSet also.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Well I am not sure that will help, but =
maybe I=20
could extract the content in that case? </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyway this EObject is not contained =
anywhere else.=20
So I guess I need to use the resource.getFragment(EObject)? But how to =
access=20
this resource? Then what to do in the deserialization step?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:e406co$vks$1@utils.eclipse.org">news:e406co$vks$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Making=20
them Serializeable would be very hard.&nbsp; Will the EObject be =
contained=20
somewhere else or will this be the only way of reaching it?&nbsp; Can =
it be in=20
another resource? &nbsp; If it's a reference to an object contained =
elsewhere=20
you could maybe wrap it when setValue is called and unwrap it when =
getValue is=20
called, and design a Serializable wrapper that uses EcoreUtil.getURI() =
to get=20
the URI for the object and then for unwrapping can use=20
=
ResourceSet.getResource(&lt;uri-with-trim-fragment&g t;).getEObject(&lt;fr=
agment-of-uri&gt;)=20
to resolve it.&nbsp; If it will be in the same resource, then=20
resource.getFragment(EObject) and resource.getEObject(&lt;fragment) =
will be=20
sufficient.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide405dm$ru7$1@utils.eclipse.org type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thank you for your help so far! I =
am almost=20
there. I did exactly as you suggested, but I have one more=20
problem:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sometimes the Object to serialize =
is an EObject=20
(one of my EMF objects of my model). Unfortunately they are not=20
serializable. Is there an easy way to mark them as Serializable or =
to=20
serialize them? </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:e3vt7o$kag$1@utils.eclipse.org">news:e3vt7o$kag$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>It=20
should serialize fine.&nbsp; The feature corresponding to the =
"<FONT=20
size=3D+0><FONT size=3D+0><FONT size=3D2><FONT size=3D2>DataSets" =
element=20
</FONT></FONT></FONT></FONT>should already be marked as a=20
containment.&nbsp; I think all you have left to do is make sure =
the=20
"value" feature serializes.<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vsoc$h2o$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry, but I think I got =
confused. If it=20
only suppress the API visibility, it's doesn't matter to me to =
expose an=20
EMap, I just want it to be serialized.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So here is my problem =
again:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have an EMap of =
String/Objects. I=20
understand the bit about serializing the Object. Do I need to do =

anything for the EMap? Should I set its containment to true or =
something=20
like that?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your =
patience,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
could use ecore:suppressedGetVisibility=3D"true" (assuming you =
are using=20
EMF 2.2) to not have the EMap method in the API.&nbsp; And =
then you=20
could add your own method by hand, and use EMap.map() to =
return a view=20
on the EMap.&nbsp; (That's such suppressing the EMF types=20
does.)<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vr8j$82v$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR>
<DIV><FONT face=3DArial size=3D2>When I set that "suppress" =
property,=20
all my EMF types will revert to java types. But I can't =
afford this=20
change now, it will break the backward compatibility of my =
model. Is=20
there a way to only apply it to this EMap? </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Or can I extend&nbsp;EMap =
to enable its=20
serialization and use this extended type =
somehow?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>David</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>You=20
need to set the GenModel property "Suppress EMF Types" to =
true for=20
an EMap to be surfaced as a java.util.Map view of the EMap =
in the=20
generated API. <BR><BR>For the "value"'s type, you should =
define a=20
new simpleType "DataSetMap" that restricts "base64Binary" =
and make=20
that the type of "value".&nbsp; For that new simple type, =
you=20
should set the ecore:instanceClassName to =
"java.util.Map".&nbsp;=20
Then, in the generated XyzFactoryImpl you'll need to =
implement the=20
create/convert methods as I outline =
earlier.<BR><BR>Hopefully I've=20
correctly understood that you want a map that maps a =
string to=20
another map....<BR><BR><BR>David Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vlpe$jkg$1@utils.eclipse.org =
type=3D"cite">
<META content=3D"MSHTML 6.00.2900.2873" =
name=3DGENERATOR>
<STYLE></STYLE>

<DIV><FONT face=3DArial size=3D2>I reloaded the xml file =
in the=20
editor and it worked!</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Now I agree to use =
java.util.Map,=20
but when I generate the model, it creates an EMap... I =
use the=20
following type:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>
<P align=3Dleft>&lt;xsd:complexType=20
ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"key"=20
type=3D"xsd:string"/&gt;</P>
<P align=3Dleft>&lt;xsd:attribute name=3D"value"=20
type=3D"xsd:anyType"/&gt;</P>
<P>&lt;/xsd:complexType&gt;</P>
<P><FONT face=3DArial>with </FONT></P><FONT size=3D2>
<P align=3Dleft>&lt;xsd:element maxOccurs=3D"unbounded"=20
name=3D"DataSets" =
type=3D"EStringToDataSetMapEntry"&gt;</P>
<P align=3Dleft>&lt;/xsd:element&gt;</P>
<P align=3Dleft>How can I force it to generate a =
java.util.Map=20
instead?</P>
<P align=3Dleft><FONT face=3DArial>I'm still not clear =
how to=20
register the EDataType, where should it go in the=20
schema?</FONT></P>
<P align=3Dleft><FONT face=3DArial>Thanks,</FONT></P>
<P align=3Dleft><FONT=20
face=3DArial>David</FONT></P></FONT></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; =
MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A=20
=
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt; wrote=20
in message <A=20
=
href=3D"news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.ecli=
pse.org</A>...</DIV>David,<BR><BR>Are=20
you using EMF 2.2?&nbsp; I think you would be better =
to use=20
schema types (xsd:string) and for EMap you'll need to =
define=20
your own type anyway.&nbsp; If you take the approach I =

outlined of serializing the value map as a base64 =
"blob", I'd=20
define a new data type that restricts base64Binary and =
defines=20
the ecore:instanceClass to be =
java.util.Map.<BR><BR><BR>David=20
Michonneau wrote:=20
<BLOCKQUOTE cite=3Dmide3vig4$rg$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
schemaLocation=3D"platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "=
/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types; =

you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as=20
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be =
an=20
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass=3D"java.util.Map$Entry"=20
name=3D"EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name=3D"key" type=3D"ecore:EString"/&gt;

&lt;xsd:attribute name=3D"value" type=3D"ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<A class=3Dmoz-txt-link-freetext =
href=3D"http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.or=
g/emf/2002/Ecore#EMap</A>' is=20
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/em=
f/2002/Ecore"</A>=20
xmlns:xsd=3D<A class=3Dmoz-txt-link-rfc2396E =
href=3D"http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSche=
ma"</A> ...&gt;

What else am I missing?

Thanks,

David





</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

=
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE ></BLOCK=
QUOTE><BR></BLOCKQUOTE></BLOCKQUOTE><BR></BLOCKQUOTE></BLOCKQUOTE ><BR></B=
LOCKQUOTE></BODY></HTML>

------=_NextPart_000_232C_01C6754B.250D1850--
Re: ecore namespace? [message #401051 is a reply to message #401046] Thu, 11 May 2006 17:25 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------070902010802020807070302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

David,

If it's not contained elsewhere, then maybe you can use
XMLHelperImpl.saveString to turn it into a string. Or even add it to a
"dummy" resource to save it to a string that way. I.e., using a
resource like a wrapper and maybe even making the derived resource
Serializable. URIConverter.ReadableInputStream/WriteableOutputStream
can help to avoid byte to char encoding and decoding.

I'm tired. So many notes today!!


David Michonneau wrote:
> This seems complicated, let me give you more details:
>
> I have this DataSet interface with setValue(Object), Object getValue().
>
> Several interface derive from DataSet: DateTimeDataSet, NumberDataSet,
> TextDataSet,...
> you can set such a specialized interface as a value in the main
> DataSet (I know it's strange, but I haven't designed it)
>
> NumberDataSet number = NumberDataSetImpl.create( new double[] { 1.0,
> 2.0, 3.0 } );
> dataSet.setValue( numberDataSet ); // for instance
> or
> dataSet.setValue (doubleArray); // another case
>
> so to summarize it, this EObject set as a value of my DataSet will be
> a DataSet also.
>
> Well I am not sure that will help, but maybe I could extract the
> content in that case?
>
> Anyway this EObject is not contained anywhere else. So I guess I need
> to use the resource.getFragment(EObject)? But how to access this
> resource? Then what to do in the deserialization step?
>
> Thanks,
>
> David
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:e406co$vks$1@utils.eclipse.org...
> David,
>
> Making them Serializeable would be very hard. Will the EObject be
> contained somewhere else or will this be the only way of reaching
> it? Can it be in another resource? If it's a reference to an
> object contained elsewhere you could maybe wrap it when setValue
> is called and unwrap it when getValue is called, and design a
> Serializable wrapper that uses EcoreUtil.getURI() to get the URI
> for the object and then for unwrapping can use
> ResourceSet.getResource(<uri-with-trim-fragment>).getEObject( <fragment-of-uri>)
> to resolve it. If it will be in the same resource, then
> resource.getFragment(EObject) and resource.getEObject(<fragment)
> will be sufficient.
>
>
> David Michonneau wrote:
>> Hi Ed,
>>
>> Thank you for your help so far! I am almost there. I did exactly
>> as you suggested, but I have one more problem:
>>
>> Sometimes the Object to serialize is an EObject (one of my EMF
>> objects of my model). Unfortunately they are not serializable. Is
>> there an easy way to mark them as Serializable or to serialize them?
>>
>> Thanks,
>>
>> David
>>
>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote
>> in message news:e3vt7o$kag$1@utils.eclipse.org...
>> David,
>>
>> It should serialize fine. The feature corresponding to the
>> "DataSets" element should already be marked as a
>> containment. I think all you have left to do is make sure
>> the "value" feature serializes.
>>
>>
>> David Michonneau wrote:
>>> Hi Ed,
>>>
>>> Sorry, but I think I got confused. If it only suppress the
>>> API visibility, it's doesn't matter to me to expose an EMap,
>>> I just want it to be serialized.
>>>
>>> So here is my problem again:
>>>
>>> I have an EMap of String/Objects. I understand the bit about
>>> serializing the Object. Do I need to do anything for the
>>> EMap? Should I set its containment to true or something like
>>> that?
>>>
>>> Thanks for your patience,
>>>
>>> David
>>>
>>> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>>
>>> wrote in message news:e3vrfk$89f$2@utils.eclipse.org...
>>> David,
>>>
>>> You could use ecore:suppressedGetVisibility="true"
>>> (assuming you are using EMF 2.2) to not have the EMap
>>> method in the API. And then you could add your own
>>> method by hand, and use EMap.map() to return a view on
>>> the EMap. (That's such suppressing the EMF types does.)
>>>
>>>
>>> David Michonneau wrote:
>>>> When I set that "suppress" property, all my EMF types
>>>> will revert to java types. But I can't afford this
>>>> change now, it will break the backward compatibility of
>>>> my model. Is there a way to only apply it to this EMap?
>>>>
>>>> Or can I extend EMap to enable its serialization and
>>>> use this extended type somehow?
>>>>
>>>> Thanks,
>>>>
>>>> David
>>>>
>>>> "Ed Merks" <merks@ca.ibm.com
>>>> <mailto:merks@ca.ibm.com>> wrote in message
>>>> news:e3vmqv$ore$1@utils.eclipse.org...
>>>> David,
>>>>
>>>> You need to set the GenModel property "Suppress EMF
>>>> Types" to true for an EMap to be surfaced as a
>>>> java.util.Map view of the EMap in the generated API.
>>>>
>>>> For the "value"'s type, you should define a new
>>>> simpleType "DataSetMap" that restricts
>>>> "base64Binary" and make that the type of "value".
>>>> For that new simple type, you should set the
>>>> ecore:instanceClassName to "java.util.Map". Then,
>>>> in the generated XyzFactoryImpl you'll need to
>>>> implement the create/convert methods as I outline
>>>> earlier.
>>>>
>>>> Hopefully I've correctly understood that you want a
>>>> map that maps a string to another map....
>>>>
>>>>
>>>> David Michonneau wrote:
>>>>> I reloaded the xml file in the editor and it worked!
>>>>>
>>>>> Now I agree to use java.util.Map, but when I
>>>>> generate the model, it creates an EMap... I use
>>>>> the following type:
>>>>>
>>>>>
>>>>> <xsd:complexType
>>>>> ecore:instanceClass="java.util.Map$Entry"
>>>>> name="EStringToDataSetMapEntry">
>>>>>
>>>>> <xsd:attribute name="key" type="xsd:string"/>
>>>>>
>>>>> <xsd:attribute name="value" type="xsd:anyType"/>
>>>>>
>>>>> </xsd:complexType>
>>>>>
>>>>> with
>>>>>
>>>>> <xsd:element maxOccurs="unbounded" name="DataSets"
>>>>> type="EStringToDataSetMapEntry">
>>>>>
>>>>> </xsd:element>
>>>>>
>>>>> How can I force it to generate a java.util.Map
>>>>> instead?
>>>>>
>>>>> I'm still not clear how to register the EDataType,
>>>>> where should it go in the schema?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> David
>>>>>
>>>>> "Ed Merks" <merks@ca.ibm.com
>>>>> <mailto:merks@ca.ibm.com>> wrote in message
>>>>> news:e3vj4q$47o$1@utils.eclipse.org...
>>>>> David,
>>>>>
>>>>> Are you using EMF 2.2? I think you would be
>>>>> better to use schema types (xsd:string) and
>>>>> for EMap you'll need to define your own type
>>>>> anyway. If you take the approach I outlined
>>>>> of serializing the value map as a base64
>>>>> "blob", I'd define a new data type that
>>>>> restricts base64Binary and defines the
>>>>> ecore:instanceClass to be java.util.Map.
>>>>>
>>>>>
>>>>> David Michonneau wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I did add this line, but it still complains, and the generator too:
>>>>>>
>>>>>> <xsd:import namespace="http://www.eclipse.org/emf/2002/Ecore"
>>>>>> schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/>
>>>>>>
>>>>>> Is it the right syntax? Otherwise, where can I find this ecore.xsd file?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> David
>>>>>>
>>>>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>>>>> news:e3vgh6$p18$1@utils.eclipse.org...
>>>>>>
>>>>>>> David,
>>>>>>>
>>>>>>> You'd need to import the Ecore.xsd to refer directly to the Ecore types;
>>>>>>> you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
>>>>>>> the schemaLocation to do that.
>>>>>>>
>>>>>>> Why not use xsd:string? Are you sure you want the itself value to be an
>>>>>>> EMap, which is a wrapper for java.util.Map and isn't serializeable?
>>>>>>>
>>>>>>> David Michonneau wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am trying to add this type in my schema file:
>>>>>>>>
>>>>>>>> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
>>>>>>>> name="EStringToDataSetMapEntry">
>>>>>>>>
>>>>>>>> <xsd:attribute name="key" type="ecore:EString"/>
>>>>>>>>
>>>>>>>> <xsd:attribute name="value" type="ecore:EMap"/>
>>>>>>>>
>>>>>>>> </xsd:complexType>
>>>>>>>>
>>>>>>>> But my XML editor complains
>>>>>>>> XSD: Type reference 'http://www.eclipse.org/emf/2002/Ecore#EMap' is
>>>>>>>> unresolved
>>>>>>>>
>>>>>>>> I added this at the beginning of the xsd file:
>>>>>>>>
>>>>>>>> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>>>>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
>>>>>>>>
>>>>>>>> What else am I missing?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> David
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


--------------070902010802020807070302
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">
David,<br>
<br>
If it's not contained elsewhere, then maybe you can use
XMLHelperImpl.saveString to turn it into a string.&nbsp; Or even add it to a
"dummy" resource to save it to a string that way.&nbsp; I.e., using a
resource like a wrapper and maybe even making the derived resource
Serializable.&nbsp; URIConverter.ReadableInputStream/WriteableOutputStream
can help to avoid byte to char encoding and decoding.&nbsp; <br>
<br>
I'm tired.&nbsp; So many notes today!!<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide4075m$2pv$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">This seems complicated, let me give
you more details:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I have this DataSet interface with
setValue(Object), Object getValue().</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Several interface derive from
DataSet: DateTimeDataSet, NumberDataSet, TextDataSet,...</font></div>
<div><font face="Arial" size="2">you can set such a specialized
interface as a value in the main DataSet (I know it's strange, but I
haven't designed it)</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">NumberDataSet number =
NumberDataSetImpl.create( new double[] { 1.0, 2.0, 3.0 } );</font></div>
<div><font face="Arial" size="2">dataSet.setValue( numberDataSet );
// for instance</font></div>
<div><font face="Arial" size="2">or </font></div>
<div><font face="Arial" size="2">dataSet.setValue (doubleArray); //
another case</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">so to summarize it, this EObject set
as a value of my DataSet will be a DataSet also.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Well I am not sure that will help,
but maybe I could extract the content in that case? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Anyway this EObject is not contained
anywhere else. So I guess I need to use the
resource.getFragment(EObject)? But how to access this resource? Then
what to do in the deserialization step?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e406co$vks$1@utils.eclipse.org">news:e406co$vks$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Making them Serializeable would be very hard.&nbsp; Will the EObject be
contained somewhere else or will this be the only way of reaching it?&nbsp;
Can it be in another resource? &nbsp; If it's a reference to an object
contained elsewhere you could maybe wrap it when setValue is called and
unwrap it when getValue is called, and design a Serializable wrapper
that uses EcoreUtil.getURI() to get the URI for the object and then for
unwrapping can use
ResourceSet.getResource(&lt;uri-with-trim-fragment&g t;).getEObject(&lt;fragment-of-uri&gt;)
to resolve it.&nbsp; If it will be in the same resource, then
resource.getFragment(EObject) and resource.getEObject(&lt;fragment)
will be sufficient.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide405dm$ru7$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">Hi Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank you for your help so far!
I am almost there. I did exactly as you suggested, but I have one more
problem:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Sometimes the Object to
serialize is an EObject (one of my EMF objects of my model).
Unfortunately they are not serializable. Is there an easy way to mark
them as Serializable or to serialize them? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vt7o$kag$1@utils.eclipse.org">news:e3vt7o$kag$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
It should serialize fine.&nbsp; The feature corresponding to the "<font
size="-0"><font size="-0"><font size="2"><font size="2">DataSets"
element </font></font></font></font>should already be marked as a
containment.&nbsp; I think all you have left to do is make sure the "value"
feature serializes.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vsoc$h2o$1@utils.eclipse.org" type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">Hi Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Sorry, but I think I got
confused. If it only suppress the API visibility, it's doesn't matter
to me to expose an EMap, I just want it to be serialized.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">So here is my problem again:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I have an EMap of
String/Objects. I understand the bit about serializing the Object. Do I
need to do anything for the EMap? Should I set its containment to true
or something like that?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks for your patience,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vrfk$89f$2@utils.eclipse.org">news:e3vrfk$89f$2@utils.eclipse.org</a>...</div>
David,<br>
<br>
You could use ecore:suppressedGetVisibility="true" (assuming you are
using EMF 2.2) to not have the EMap method in the API.&nbsp; And then you
could add your own method by hand, and use EMap.map() to return a view
on the EMap.&nbsp; (That's such suppressing the EMF types does.)<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vr8j$82v$1@utils.eclipse.org"
type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<div><font face="Arial" size="2">When I set that
"suppress" property, all my EMF types will revert to java types. But I
can't afford this change now, it will break the backward compatibility
of my model. Is there a way to only apply it to this EMap? </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Or can I extend&nbsp;EMap to
enable its serialization and use this extended type somehow?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">David</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:e3vmqv$ore$1@utils.eclipse.org">news:e3vmqv$ore$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
You need to set the GenModel property "Suppress EMF Types" to true for
an EMap to be surfaced as a java.util.Map view of the EMap in the
generated API. <br>
<br>
For the "value"'s type, you should define a new simpleType "DataSetMap"
that restricts "base64Binary" and make that the type of "value".&nbsp; For
that new simple type, you should set the ecore:instanceClassName to
"java.util.Map".&nbsp; Then, in the generated XyzFactoryImpl you'll need to
implement the create/convert methods as I outline earlier.<br>
<br>
Hopefully I've correctly understood that you want a map that maps a
string to another map....<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vlpe$jkg$1@utils.eclipse.org"
type="cite">
<meta content="MSHTML 6.00.2900.2873" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I reloaded the xml
file in the editor and it worked!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I agree to use
java.util.Map, but when I generate the model, it creates an EMap... I
use the following type:</font></div>
<div>&nbsp;</div>
<div><font size="2">
<p align="left">&lt;xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;xsd:attribute name="key"
type="xsd:string"/&gt;</p>
<p align="left">&lt;xsd:attribute name="value"
type="xsd:anyType"/&gt;</p>
<p>&lt;/xsd:complexType&gt;</p>
<p><font face="Arial">with </font></p>
<font size="2">
<p align="left">&lt;xsd:element maxOccurs="unbounded"
name="DataSets" type="EStringToDataSetMapEntry"&gt;</p>
<p align="left">&lt;/xsd:element&gt;</p>
<p align="left">How can I force it to generate a
java.util.Map instead?</p>
<p align="left"><font face="Arial">I'm still not
clear how to register the EDataType, where should it go in the schema?</font></p>
<p align="left"><font face="Arial">Thanks,</font></p>
<p align="left"><font face="Arial">David</font></p>
</font></font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a
href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt; wrote in
message <a href="news:e3vj4q$47o$1@utils.eclipse.org">news:e3vj4q$47o$1@utils.eclipse.org</a>...</div>
David,<br>
<br>
Are you using EMF 2.2?&nbsp; I think you would be better to use schema types
(xsd:string) and for EMap you'll need to define your own type anyway.&nbsp;
If you take the approach I outlined of serializing the value map as a
base64 "blob", I'd define a new data type that restricts base64Binary
and defines the ecore:instanceClass to be java.util.Map.<br>
<br>
<br>
David Michonneau wrote:
<blockquote cite="mide3vig4$rg$1@utils.eclipse.org"
type="cite">
<pre wrap="">Hi,

I did add this line, but it still complains, and the generator too:

&lt;xsd:import namespace=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
schemaLocation="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd "/&gt;

Is it the right syntax? Otherwise, where can I find this ecore.xsd file?

Thanks,

David

"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext"
href="news:e3vgh6$p18$1@utils.eclipse.org">news:e3vgh6$p18$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">David,

You'd need to import the Ecore.xsd to refer directly to the Ecore types;
you could use platform:/plugin/org.eclipse.emf.ecore/model/Ecore.xsd as
the schemaLocation to do that.

Why not use xsd:string? Are you sure you want the itself value to be an
EMap, which is a wrapper for java.util.Map and isn't serializeable?

David Michonneau wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I am trying to add this type in my schema file:

&lt;xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToDataSetMapEntry"&gt;

&lt;xsd:attribute name="key" type="ecore:EString"/&gt;

&lt;xsd:attribute name="value" type="ecore:EMap"/&gt;

&lt;/xsd:complexType&gt;

But my XML editor complains
XSD: Type reference '<a class="moz-txt-link-freetext"
href="http://www.eclipse.org/emf/2002/Ecore#EMap">http://www.eclipse.org/emf/2002/Ecore#EMap</a>' is
unresolved

I added this at the beginning of the xsd file:

&lt;xsd:schema xmlns:ecore=<a class="moz-txt-link-rfc2396E"
href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
xmlns:xsd=<a class="moz-txt-link-rfc2396E"
href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> ...&gt;

What else am I missing?

Thanks,

David





</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------070902010802020807070302--
Previous Topic:EMF for C++
Next Topic:Roundtripping EDiagram editor as Eclipse Google Summer Of Code project?
Goto Forum:
  


Current Time: Mon Sep 08 14:21:02 EDT 2025

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

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

Back to the top