XML and Content Types [message #334955] |
Wed, 11 March 2009 13:54  |
Eclipse User |
|
|
|
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 17:46  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03220 seconds