XMLRootElementContentDescriber and element with colons [message #324728] |
Thu, 31 January 2008 07:24  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #324757 is a reply to message #324751] |
Thu, 31 January 2008 11:43  |
Eclipse User |
|
|
|
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!
>
|
|
|
Powered by
FUDForum. Page generated in 0.04117 seconds