|
|
Re: Getting the Resource.Factory from the EPackage [message #417073 is a reply to message #417070] |
Mon, 25 February 2008 20:29 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060908000706030105040802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Will,
It's quite possible for a given package's instance to be serialized in
multiple different ways. For example, an Ecore EPackage can be
serialized as a *.ecore the normal way, or using EMOF syntax in a *.emof
file that uses EMOFResourceFactoryImpl. So generally there is no way to
map from a package to a resource factory to be used for that package.
With the advent of content types in EMF 2.4, it will be possible to
register in a more flexible way. For example, in the xmi plugin we
register any resource ending with *.ecore or *.xmi that contains a root
element form the Ecore namespace to be considered to be of type
"org.eclipse.emf.ecore"
<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
file-extensions="ecore,xmi"
id="org.eclipse.emf.ecore"
name="%_UI_Ecore_content_type"
priority="normal">
<describer
class=" org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl$Des criber ">
<parameter
name="namespace"
value="http://www.eclipse.org/emf/2002/Ecore">
</parameter>
<parameter
name="kind"
value="xmi">
</parameter>
</describer>
</content-type>
</extension>
And we register the EcoreResourceFactoryImpl against that content type
identifier.
<extension
point="org.eclipse.emf.ecore.content_parser">
<parser
class="org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl "
contentTypeIdentifier="org.eclipse.emf.ecore">
</parser>
</extension>
So with EMF 2.4, you can use the above mechanism to register a factory
based the contents within the *.xml resource...
Will Horn wrote:
> I should add that the resources are XML files and all have the same
> ".xml" extension.
>
> Will Horn wrote:
>> I have multiple models being managed in the same ResourceSet. When a
>> resource is going to be created, I know from the URI which model I am
>> dealing with, but currently only by an EPackage reference.
>>
>> Is there a way to get the generated Resource.Factory from the
>> EPackage? Or do I need to map the URI to the Resource.Factory
>> separately.
>>
>> Thanks,
>> Will
--------------060908000706030105040802
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">
Will,<br>
<br>
It's quite possible for a given package's instance to be serialized in
multiple different ways. For example, an Ecore EPackage can be
serialized as a *.ecore the normal way, or using EMOF syntax in a
*.emof file that uses EMOFResourceFactoryImpl. So generally there is
no way to map from a package to a resource factory to be used for that
package. With the advent of content types in EMF 2.4, it will be
possible to register in a more flexible way. For example, in the xmi
plugin we register any resource ending with *.ecore or *.xmi that
contains a root element form the Ecore namespace to be considered to be
of type "<small>org.eclipse.emf.ecore"</small>
<blockquote><small> <extension</small><br>
<small> point="org.eclipse.core.runtime.contentTypes"></small ><br>
<small> <content-type</small><br>
<small> base-type="org.eclipse.core.runtime.xml"</small><br>
<small> file-extensions="ecore,xmi"</small><br>
<small> id="org.eclipse.emf.ecore"</small><br>
<small> name="%_UI_Ecore_content_type"</small><br>
<small> priority="normal"></small><br>
<small> <describer</small><br>
<small>
class=" org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl$Des criber "></small><br>
<small> <parameter</small><br>
<small> name="namespace"</small><br>
<small>
value=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>></small><br>
<small> </parameter></small><br>
<small> <parameter</small><br>
<small> name="kind"</small><br>
<small> value="xmi"></small><br>
<small> </parameter></small><br>
<small> </describer></small><br>
<small> </content-type></small><br>
<small> </extension></small><br>
</blockquote>
And we register the EcoreResourceFactoryImpl against that content type
identifier.<br>
<blockquote><small> <extension<br>
point="org.eclipse.emf.ecore.content_parser"><br>
<parser<br>
class="org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl "<br>
contentTypeIdentifier="org.eclipse.emf.ecore"><br>
</parser><br>
</extension></small><br>
</blockquote>
So with EMF 2.4, you can use the above mechanism to register a factory
based the contents within the *.xml resource...<br>
<br>
<br>
Will Horn wrote:
<blockquote cite="mid:fpv6o2$itt$2@build.eclipse.org" type="cite">I
should add that the resources are XML files and all have the same
".xml" extension.
<br>
<br>
Will Horn wrote:
<br>
<blockquote type="cite">I have multiple models being managed in the
same ResourceSet. When a resource is going to be created, I know from
the URI which model I am dealing with, but currently only by an
EPackage reference.
<br>
<br>
Is there a way to get the generated Resource.Factory from the EPackage?
Or do I need to map the URI to the Resource.Factory separately.
<br>
<br>
Thanks,
<br>
Will
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>
--------------060908000706030105040802--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Getting the Resource.Factory from the EPackage [message #417076 is a reply to message #417073] |
Mon, 25 February 2008 21:26 |
Will Horn Messages: 265 Registered: July 2009 |
Senior Member |
|
|
Thanks Ed, that looks exactly like what I'm looking for.
Ed Merks wrote:
> Will,
>
> It's quite possible for a given package's instance to be serialized in
> multiple different ways. For example, an Ecore EPackage can be
> serialized as a *.ecore the normal way, or using EMOF syntax in a *.emof
> file that uses EMOFResourceFactoryImpl. So generally there is no way to
> map from a package to a resource factory to be used for that package.
> With the advent of content types in EMF 2.4, it will be possible to
> register in a more flexible way. For example, in the xmi plugin we
> register any resource ending with *.ecore or *.xmi that contains a root
> element form the Ecore namespace to be considered to be of type
> "org.eclipse.emf.ecore"
>
> <extension
> point="org.eclipse.core.runtime.contentTypes">
> <content-type
> base-type="org.eclipse.core.runtime.xml"
> file-extensions="ecore,xmi"
> id="org.eclipse.emf.ecore"
> name="%_UI_Ecore_content_type"
> priority="normal">
> <describer
>
> class=" org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl$Des criber ">
> <parameter
> name="namespace"
> value="http://www.eclipse.org/emf/2002/Ecore">
> </parameter>
> <parameter
> name="kind"
> value="xmi">
> </parameter>
> </describer>
> </content-type>
> </extension>
>
> And we register the EcoreResourceFactoryImpl against that content type
> identifier.
>
> <extension
> point="org.eclipse.emf.ecore.content_parser">
> <parser
>
> class="org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl "
> contentTypeIdentifier="org.eclipse.emf.ecore">
> </parser>
> </extension>
>
> So with EMF 2.4, you can use the above mechanism to register a factory
> based the contents within the *.xml resource...
>
>
> Will Horn wrote:
>> I should add that the resources are XML files and all have the same
>> ".xml" extension.
>>
>> Will Horn wrote:
>>> I have multiple models being managed in the same ResourceSet. When a
>>> resource is going to be created, I know from the URI which model I am
>>> dealing with, but currently only by an EPackage reference.
>>>
>>> Is there a way to get the generated Resource.Factory from the
>>> EPackage? Or do I need to map the URI to the Resource.Factory
>>> separately.
>>>
>>> Thanks,
>>> Will
>
|
|
|
Powered by
FUDForum. Page generated in 0.02824 seconds