Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » XML and Content Types
XML and Content Types [message #334955] Wed, 11 March 2009 17:54 Go to next message
Nadeem Aboobaker is currently offline Nadeem AboobakerFriend
Messages: 20
Registered: July 2009
Junior Member
Hi All,

I'm trying to define a content type for XML files that have a specific
root element and namespace. I did some searching and found that using the
XMLRootElementContentDescriber2 describer class should get me what I want.
I then hooked up an editor to the content type, and double clicking on
the file opens the correct editor in some cases, but not all.

Here's how I defined the content type:

<extension point="org.eclipse.core.runtime.contentTypes">
<content-type id="exampleID"
name="Example XML Content Type"
base-type="org.eclipse.core.runtime.xml"
priority="high"
file-extensions="xml">
<describer
class=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber2 ">
<parameter name="element"
value="{http://www.example.com/ex}example"/>
</describer>
</content-type>
</extension>


1. As expected, the editor opens when double clicking on XML files that
look like:

<example xmlns="http://www.example.com/ex">
...
</example>


2. As expected, the editor does not open for XML files that look like:

<example>
...
</example>


3. Not as expected, the editor does NOT open for XML files that look like:
<ex:example ex:xmlns="http://www.example.com/ex">
...
</ex:example>


I tried removing the namespace from the content type definition
(value="example") and that changed case #2 to open in the editor, but case
#3 still does not.

Any ideas what I'm doing wrong? Or is this not supported by
XMLRootElementContentDescriber2?

Thanks,
Nadeem
Re: XML and Content Types [message #334959 is a reply to message #334955] Wed, 11 March 2009 21:46 Go to previous message
Nadeem Aboobaker is currently offline Nadeem AboobakerFriend
Messages: 20
Registered: July 2009
Junior Member
Of course the problem turned out to be obvious... I accidentally messed
up the namespace-prefix binding (switched "ex" and "xmlns"). Now
everything works as it should.

- Nadeem


Nadeem wrote:

> Hi All,

> I'm trying to define a content type for XML files that have a specific
> root element and namespace. I did some searching and found that using the
> XMLRootElementContentDescriber2 describer class should get me what I want.
> I then hooked up an editor to the content type, and double clicking on
> the file opens the correct editor in some cases, but not all.

> Here's how I defined the content type:

> <extension point="org.eclipse.core.runtime.contentTypes">
> <content-type id="exampleID"
> name="Example XML Content Type"
> base-type="org.eclipse.core.runtime.xml"
> priority="high"
> file-extensions="xml">
> <describer
> class=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber2 ">
> <parameter name="element"
> value="{http://www.example.com/ex}example"/>
> </describer>
> </content-type>
> </extension>


> 1. As expected, the editor opens when double clicking on XML files that
> look like:

> <example xmlns="http://www.example.com/ex">
> ...
> </example>


> 2. As expected, the editor does not open for XML files that look like:

> <example>
> ...
> </example>


> 3. Not as expected, the editor does NOT open for XML files that look like:
> <ex:example ex:xmlns="http://www.example.com/ex">
> ...
> </ex:example>


> I tried removing the namespace from the content type definition
> (value="example") and that changed case #2 to open in the editor, but case
> #3 still does not.

> Any ideas what I'm doing wrong? Or is this not supported by
> XMLRootElementContentDescriber2?

> Thanks,
> Nadeem
Previous Topic:How to handle changes to workspace outside Eclipse with a Job
Next Topic:TabbedPropertySheetPage reorganization
Goto Forum:
  


Current Time: Fri Nov 08 22:48:18 GMT 2024

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

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

Back to the top