[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: XMLRootElementContentDescriber and element with colons

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$Describer">
<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,