Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » XMLRootElementContentDescriber and element with colons
XMLRootElementContentDescriber and element with colons [message #324728] Thu, 31 January 2008 07:24 Go to next message
Eclipse UserFriend
Hello,

I've been trying to create a contextual menu entry that would only
appear when the selected item is a xml file whose top element name
contains a colon (like foo:foo for example) and it won't work. The menu
entry never appears. I simply use a contentTypes extension with an
XMLRootElementContentDescriber. It works if I change the top element
parameter of my content describer to "foo" and I modify my xml file so
that its top element is now "foo".


Also, even if I have not specified any constraint on the filename
extension, only .xml files are checked and I would want to enable this
menu entry for files with the extension I desire. Typically, I want to
check if an Ecore model (like example.mylist) has a certain root element
(mylist:Elt).

Best regards,

--
Damien THIVOLLE
Re: XMLRootElementContentDescriber and element with colons [message #324729 is a reply to message #324728] Thu, 31 January 2008 07:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Damien,

Maybe you want to be using EMF's 2.4's new support for content types?
There isn't much documentation for it though, but what else is new?

Here's an example in the plugin.xml for the xmi plugin that defines a
content type for Ecore itself:

<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>

With this type of approach, you can use EMF's more flexible and
extensible implementations for doing your content type checking. You do
need to specify the extensions of the files for which the content type
is applicable, but users can "Add..." to this dynamically:


Likely you want something just like we have for Ecore. I.e., something
that recognizes when the root element comes from your models namespace;
it's also possible to restrict the names of the elements in addition to
just specifying the namespace. If you look at the Javadoc, you'll get
the idea of what you can specify.


Damien Thivolle wrote:
> Hello,
>
> I've been trying to create a contextual menu entry that would only
> appear when the selected item is a xml file whose top element name
> contains a colon (like foo:foo for example) and it won't work. The
> menu entry never appears. I simply use a contentTypes extension with
> an XMLRootElementContentDescriber. It works if I change the top
> element parameter of my content describer to "foo" and I modify my xml
> file so that its top element is now "foo".
>
>
> Also, even if I have not specified any constraint on the filename
> extension, only .xml files are checked and I would want to enable this
> menu entry for files with the extension I desire. Typically, I want to
> check if an Ecore model (like example.mylist) has a certain root
> element (mylist:Elt).
>
> Best regards,
>
Re: XMLRootElementContentDescriber and element with colons [message #324751 is a reply to message #324729] Thu, 31 January 2008 10:59 Go to previous messageGo to next message
Eclipse UserFriend
Ed Merks a écrit :
> Damien,

Hello again :)

>
> Maybe you want to be using EMF's 2.4's new support for content types?
> There isn't much documentation for it though, but what else is new?
>
> Here's an example in the plugin.xml for the xmi plugin that defines a
> content type for Ecore itself:
>
> <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>

So, I've downloaded Eclipse 3.4 and EMF 2.4. I did exactly as you said,
I replaced http://www.eclipse.org/emf/2002/Ecore by
http://www.topcased.org/SAM/1.0, I changed the file-extensions to match
my needs and it just works perfectly :)

Thanks a lot!

--
Damien THIVOLLE | INRIA Rhone-Alpes / VASY
PHD Student | 655, Avenue de l'Europe
damien.thivolle@inria.fr | Montbonnot
http://www.inrialpes.fr/vasy | 38 334 Saint Ismier Cedex France
Re: XMLRootElementContentDescriber and element with colons [message #324757 is a reply to message #324751] Thu, 31 January 2008 11:43 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Damien,

Cool. It's almost as if I anticipated your needs! :-P

Damien Thivolle wrote:
> Ed Merks a écrit :
>> Damien,
>
> Hello again :)
>
>>
>> Maybe you want to be using EMF's 2.4's new support for content
>> types? There isn't much documentation for it though, but what else
>> is new?
>>
>> Here's an example in the plugin.xml for the xmi plugin that defines a
>> content type for Ecore itself:
>>
>> <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>
>
> So, I've downloaded Eclipse 3.4 and EMF 2.4. I did exactly as you
> said, I replaced http://www.eclipse.org/emf/2002/Ecore by
> http://www.topcased.org/SAM/1.0, I changed the file-extensions to
> match my needs and it just works perfectly :)
>
> Thanks a lot!
>
Previous Topic:Key bindings for Eclipse-Commands
Next Topic:Disabling Software Updates
Goto Forum:
  


Current Time: Thu Sep 18 10:36:17 EDT 2025

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

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

Back to the top