<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Eclipse File Content Types
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/bbrodt">Robert (Bob) Brodt</a> in <i>JBoss Tools Development</i> - <a href="http://community.jboss.org/docs/DOC-15183">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h1>The Big Picture</h1><p style="margin-bottom: 0in;"><a href="http://community.jboss.org/servlet/JiveServlet/showImage/2580/soup.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/2580/57-97/soup.jpg </span></a>When you pick up a can of soup and the label reads &ldquo;TOMATO SOUP&#8221;, you expect tomato soup to be inside, right? What if soup manufacturers all decided not to label their products and simply used generic containers with the label &ldquo;SOUP&#8221;? One could argue that even if the soup cans were clearly labeled, who's to say that what's inside really is TOMATO SOUP? The only way to be absolutely certain is to open the can and peek inside!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in;">Since the dawn of MS-DOS, file name extensions have been used, much like soup can labels, to identify file contents and, typically which application is associated with that file. Eclipse has been following this same tried-and-true philosophy to launch the proper editor or viewer plugin when you double-click on a resource in the eclipse Navigator. But with the proliferation of XML formats that describe everything from <a class="jive-link-external-small" href="http://graffitianalysis.com/gml/">graffiti</a> to <a class="jive-link-external-small" href="http://xml.coverpages.org/geml.html">DNA patterns</a>, the file name extension &ldquo;XML&#8221; has become somewhat ambiguous. OK, we know it's SOUP but what <strong>kind</strong> of SOUP?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in;">That's essentially the idea behind the eclipse <a class="jive-link-external-small" href="http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/runtime_content_contributing.htm">content-type</a> extension point. When the eclipse workbench opens a folder resource for the first time, it looks at the folder's contained IFile resources and then all plugins that contribute to this extension point are allowed to &ldquo;peek inside the can&#8221; to see if it contains a SOUP that they can consume. The extension point then provides an ID which is is associated with the IFile and cached by the workbench. If the name of the IFile changes, the workbench goes through the same content type checking again.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in;">As you can imagine, the time it takes for the workbench to run through this process increases (roughly) with the number of plugins that contribute to content-type multiplied by the number of files in your projects. So, as a plugin developer you need to ensure that content type checking is as fast as possible: peek inside the can, take a quick sniff and move on; don't grab a spoon and try to take a taste!</p><h1>The Details</h1><p style="margin-bottom: 0in;">If you have been around eclipse long enough you probably already know that the SDK documentation was written by Captain Obvious and is of little help when you're trying figure out how to do something that should be so...simple. Case-in-point:</p><h2 style="margin-left: 0.49in;">Package org.eclipse.core.runtime.content</h2><p style="margin-left: 0.49in;">Provides core support for content types.</p><p style="margin-left: 0.49in;"><strong>See:</strong> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a class="jive-link-external-small" href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/content/package-summary.html?resultof=%22%49%43%6F%6E%74%65%6E%74%44%65%73%63%72%69%62%65%72%22%20%22%69%63%6F%6E%74%65%6E%74%64%65%73%63%72%69%62%22%20#package_description"><strong>Description</strong></a></p><dl><dd> <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse; width: 610px; height: 118px;"><col width="132*"></col> <col width="124*"></col> <tbody><tr bgcolor="#ccccff"><th colspan="2" style="width: 100%; background-color: rgb(204, 204, 255);"><p><span style="font-size: 18pt;"><strong>Interface Summary</strong></span></p></th></tr><tr bgcolor="#ffffff"><td width="52%"><p><a class="jive-link-external-small" href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/content/IContentDescriber.html"><strong>IContentDescriber</strong></a></p></td><td width="48%"><p>Content describers describe contents.</p></td></tr><tr bgcolor="#ffffff"><td width="52%"><p><a class="jive-link-external-small" href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/content/IContentDescription.html"><strong>IContentDescription</strong></a></p></td><td width="48%"><p>A description for content.</p></td></tr><tr bgcolor="#ffffff"><td width="52%"><p><a class="jive-link-external-small" href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/content/IContentTypeManager.html"><strong>IContentTypeManager</strong></a></p></td><td width="48%"><p>Content type managers manage content types.</p></td></tr></tbody></table></dd></dl><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><dl><dd> <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse; width: 609px; height: 95px;"><col width="146*"></col> <col width="110*"></col> <tbody><tr bgcolor="#ccccff"><th colspan="2" style="width: 100%; background-color: rgb(204, 204, 255);"><p><span style="font-size: 18pt;"><strong>Class Summary</strong></span></p></th></tr><tr bgcolor="#ffffff"><td width="57%"><p><a class="jive-link-external-small" href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/content/BinarySignatureDescriber.html"><strong>BinarySignatureDescriber</strong></a></p></td><td width="43%"><p>A describer for binary signatures.</p></td></tr><tr bgcolor="#ffffff"><td width="57%"><p><a class="jive-link-external-small" href="http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/content/XMLRootElementContentDescriber.html"><strong>XMLRootElementContentDescriber</strong></a></p></td><td width="43%"><p>A content describer for XML root elements.</p></td></tr></tbody></table></dd></dl><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Luckily there are a lot of folks out there doing amazing work with eclipse and publishing their experiences. I just wanted to give something back by describing the steps I took to add this feature to the eclipse <a class="jive-link-external-small" href="http://eclipse.org/bpel/">BPEL editor</a>.</p><p>The &ldquo;org.eclipse.ui.editors&#8221; extension point in your plugin.xml probably looks something like this:</p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;extension</span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">point=</span><span style="color: #008000;">"org.eclipse.ui.editors"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160; </span><span style="color: #000080; font-family: Monospace;">&lt;editor</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">class=</span><span style="color: #008000;">"org.eclipse.bpel.ui.BPELMultipageEditorPart"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">default=</span><span style="color: #008000;">"true"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;"><strong>extensions=</strong></span><span style="color: #008000;"><strong>"bpel"</strong></span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;"><strong>icon=</strong></span><span style="color: #008000;"><strong>"icons/obj16/bpel.gif"</strong></span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">id=</span><span style="color: #008000;">"org.eclipse.bpel.ui.bpeleditor"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">name=</span><span style="color: #800080;">"%BPEL_EDITOR_NAME"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160; </span><span style="color: #000080; font-family: Monospace;">&lt;/editor&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;/extension&gt;</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>There are a couple of things wrong with this if you intend to do content type checking: first, do not specify file extensions here since this defeats the purpose of the content-type extension point; second, do not specify an icon for your editor here either, since the workbench will slap this decorator on all files based on their file extension instead of their content. Instead, replace these attributes with the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;extension</span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">point=</span><span style="color: #008000;">"org.eclipse.ui.editors"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160; </span><span style="color: #000080; font-family: Monospace;">&lt;editor</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">class=</span><span style="color: #008000;">"org.eclipse.bpel.ui.BPELMultipageEditorPart"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">default=</span><span style="color: #008000;">"true"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">id=</span><span style="color: #008000;">"org.eclipse.bpel.ui.bpeleditor"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">name=</span><span style="color: #800080;">"%BPEL_EDITOR_NAME"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160; </span><span style="color: #000080; font-family: Monospace;"><strong>&lt;contentTypeBinding</strong></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;"><strong>contentTypeId=</strong></span><span style="color: #008000;"><strong>"org.eclipse.bpel.contenttype"</strong></span><span style="color: #000080;"><strong>&gt;</strong></span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160; </span><span style="color: #000080; font-family: Monospace;"><strong>&lt;/contentTypeBinding&gt;</strong></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160; </span><span style="color: #000080; font-family: Monospace;">&lt;/editor&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;/extension&gt;</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The contentTypeBinding element references a type ID which is defined in the content-type extension point:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;extension</span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">&#160;&#160;&#160; point=</span><span style="color: #008000;">"org.eclipse.core.contenttype.contentTypes"</span><span style="color: #000080;">&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;content-type</span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">base-type=</span><span style="color: #008000;">"org.eclipse.core.runtime.xml"</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">id=</span><span style="color: #008000;">"org.eclipse.bpel.contenttype"</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">name=</span><span style="color: #008000;">"BPEL Editor File"</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">file-extensions=</span><span style="color: #008000;">"bpel,bpel2,xml"</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">priority=</span><span style="color: #008000;">"normal"</span><span style="color: #000080;">&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;describer</span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">class=</span><span style="color: #008000;">"org.eclipse.core.runtime.content.XMLRootElementContentDescriber2"</span><span style="color: #000080;">&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;parameter</span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000080;"> </span><span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">name=</span><span style="color: #008000;">"element"</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #008000;"> </span><span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">value=</span><span style="color: #008000;">"{<a class="jive-link-external-small" href="http://docs.oasis-open.org/wsbpel/2.0/process/executable" target="_blank">http://docs.oasis-open.org/wsbpel/2.0/process/executable</a>}process"</span><span style="color: #000080;">/&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;/describer&gt;</span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;">&#160; </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;/content-type&gt;</span></p><p style="margin-right: -0.13in; margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;/extension&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm not going to repeat the eclipse reference documentation here, but I did want to make a few comments.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ol><li><p>Notice the file-extensions attribute is specified here, and you will still need to provide at least one file name extension for your content type. As of eclipse 3.5.2 <a class="jive-link-external-small" href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=46297">file name extensions are still required</a> &ndash; you can not, for example, create an XML file that has no file name extension and expect the XML editor to correctly recognize it based on content.</p></li><li><p>The eclipse framework already provides an XML root element content describer and there are lots of examples out there that demonstrate how to use it. Note however, that a lot fo these examples refer to the deprecated class XMLRootElementContentDescriber - you should use XMLRootElementContentDescriber2 defined in the org.eclipse.core.runtime.content package instead.</p></li><li><p>Whenever possible, provide a namespace for your root element. This will avoid possible conflicts with other plugins. For example, I discovered (after much gnashing of teeth) that JBoss Drools Flow editor files (*.rf files) also have a &ldquo;process&#8221; root element.</p></li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The icon attribute in the org.eclipse.editors extension point should be removed and specified in an org.eclipse.ui.decorators extension point instead, like so:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;extension</span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">point=</span><span style="color: #008000;">"org.eclipse.ui.decorators"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;decorator</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">adaptable=</span><span style="color: #008000;">"true"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="font-family: Monospace;"><span style="color: #000080;">icon=</span><span style="color: #008000;">"icons/obj16/bpel.gif"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">id=</span><span style="color: #008000;">"org.eclipse.bpel.ui.icondecorator"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">label=</span><span style="color: #008000;">"BPEL Resource Decorator"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">lightweight=</span><span style="color: #008000;">"true"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">location=</span><span style="color: #008000;">"TOP_LEFT"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">state=</span><span style="color: #008000;">"true"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;enablement&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;and&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;objectClass</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">name=</span><span style="color: #008000;">"org.eclipse.core.resources.IFile"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;/objectClass&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;objectState</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">name=</span><span style="color: #008000;">"contentTypeId"</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-family: Monospace;"><span style="color: #000080;">value=</span><span style="color: #008000;">"org.eclipse.bpel.contenttype"</span><span style="color: #000080;">&gt;</span></span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;"> &lt;/objectState&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;">&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #000080; font-family: Monospace;">&lt;/and&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160;&#160;&#160; </span><span style="color: #000080; font-family: Monospace;">&lt;/enablement&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;">&#160;&#160; </span><span style="color: #000080; font-family: Monospace;">&lt;/decorator&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="font-size: 10pt;"><span style="color: #000000;"> </span><span style="color: #000080; font-family: Monospace;">&lt;/extension&gt;</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This will ensure that your editor's files will always display the correct icon regardless of what the file name extension is, as long as it's one of the extensions declared by your content-type.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The last point I wanted to discuss was EMF support for content types. As far as I can tell this has been around since EMF 2.2.2 (possibly earlier). If your editor uses an EMF model, you also need to contribute an EMF content parser extension point:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">&lt;extension</span><span style="color: #000000;"> </span><span style="color: #000080;">point=</span><span style="color: #008000;">"org.eclipse.emf.ecore.content_parser"</span><span style="color: #000080;">&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;parser</span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">class=</span><span style="color: #008000;">"org.eclipse.bpel.model.resource.BPELResourceFactoryImpl"</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160;&#160;&#160; <span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: Monospace; "><span style="color: #000080;">contentTypeIdentifier=</span><span style="color: #008000;">"org.eclipse.bpel.contenttype"</span><span style="color: #000080;">&gt;</span></span></p><p style="margin-bottom: 0in; padding-left: 30px;">&#160; <span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;/parser&gt;</span></p><p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #000000;"> </span><span style="color: #000080; font-size: 10pt; font-family: Monospace; ">&lt;/extension&gt;</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The resource factory is then responsible for constructing the correct XMI parser for your EMF model.</p><p>Finally, don't forget to go through your editor code and replace all of the file name extension checking with content type checking! For example, stuff like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160; IResource res;</span></p><p style="margin-bottom: 0in; font-weight: normal;"><span style="font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160; <span style="font-size: 8pt;"><span style="color: #7f0055; font-size: 8pt;"><strong>if</strong></span><span style="color: #000000; font-size: 8pt;"> (res.getType() == IResource.</span><span style="color: #0000c0; font-size: 8pt;"><em>FILE</em></span><span style="color: #000000; font-size: 8pt;">) {</span></span></span></p><p style="margin-bottom: 0in; font-weight: normal;"><span style="font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-size: 8pt;"><span style="color: #7f0055; font-size: 8pt;"><strong>if</strong></span><span style="color: #000000; font-size: 8pt;"> (</span><span style="color: #2a00ff; font-size: 8pt;">"bpel"</span><span style="color: #000000; font-size: 8pt;">.equalsIgnoreCase(((IFile)res).getFileExtension())) {</span></span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #3f7f5f; font-size: 8pt; ">// load it...</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160; }</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>should be replaced with this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160; IResource res;</span></span></p><p style="margin-bottom: 0in; font-weight: normal;"><span style="font-size: 8pt;"><span style="font-family: courier new,courier;"> </span><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #7f0055; font-size: 8pt;"><strong>&#160;&#160;&#160; if</strong></span><span style="color: #000000; font-size: 8pt;"> (res.getType() == IResource.</span><span style="color: #0000c0; font-size: 8pt;"><em>FILE</em></span><span style="color: #000000; font-size: 8pt;">) {</span></span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; IContentDescription desc = ((IFile)res).getContentDescription();</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt;"><span style="font-family: courier new,courier;"> </span><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #7f0055; font-size: 8pt;"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if</strong></span><span style="color: #000000; font-size: 8pt;"> (desc != </span><span style="color: #7f0055; font-size: 8pt;"><strong>null</strong></span><span style="color: #000000; font-size: 8pt;">) {</span></span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IContentType type = desc.getContentType();</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt;"><span style="font-family: courier new,courier;"> </span><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #7f0055; font-size: 8pt;"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if</strong></span><span style="color: #000000; font-size: 8pt;"> (</span><span style="color: #2a00ff; font-size: 8pt;">"org.eclipse.bpel.contenttype"</span><span style="color: #000000; font-size: 8pt;">.equals(</span><span style="color: #000000; font-size: 8pt;">type.getId())) {</span></span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt;"><span style="font-family: courier new,courier;"> </span><span style="color: #3f7f5f; font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // load it...</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "> <span style="font-size: 8pt;">&#160;&#160;&#160;&#160; }</span></span></p><h1>Going Further</h1><p>The XMLRootElementContentDescriber2 provided by eclipse should fill most of your content type checking needs. But, if you need to drill down deeper into the XML document, you may need to write your own custom content describer class. Keep in mind though that your implementation should only do the absolute bare minimum required to make its determination &ndash; for instance don't read the entire document using a DOM parser if you only need to check a couple of elements!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Techniques that work well are to use either an <a class="jive-link-external-small" href="http://www.xmlpull.org/">XML pull parser</a> or use the SAX parser and throw exceptions to terminate parsing after the first element.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've provided an example of my BPEL content describer using a SAX parser for your reading enjoyment:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>class</strong></span><span style="color: #000000;"> BPELContentDescriber </span><span style="color: #7f0055;"><strong>implements</strong></span><span style="color: #000000;"> ITextContentDescriber {</span></span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #7f0055;"><strong>&#160; private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>static</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>final</strong></span><span style="color: #000000;"> String </span><span style="color: #0000c0;"><em>WSBPEL_2_NAMESPACE</em></span><span style="color: #000000;"> = </span><span style="color: #2a00ff;">"<a class="jive-link-external-small" href="http://docs.oasis-open.org/wsbpel/2.0/process/executable" target="_blank">http://docs.oasis-open.org/wsbpel/2.0/process/executable</a>"</span><span style="color: #000000;">; </span><span style="color: #3f7f5f;">//$NON-NLS-1$</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>&#160; private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>static</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>final</strong></span><span style="color: #000000;"> String </span><span style="color: #0000c0;"><em>ROOT_ELEMENT</em></span><span style="color: #000000;"> = </span><span style="color: #2a00ff;">"process"</span><span style="color: #000000;">; </span><span style="color: #3f7f5f;">//$NON-NLS-1$</span></span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>&#160; private</strong></span><span style="color: #000000;"> RootElementParser </span><span style="color: #0000c0;">parser</span><span style="color: #000000;"> = </span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> RootElementParser();</span></span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>&#160; public</strong></span><span style="color: #000000;"> BPELContentDescriber() {</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>int</strong></span><span style="color: #000000;"> describe(Reader contents, IContentDescription description) </span><span style="color: #7f0055;"><strong>throws</strong></span><span style="color: #000000;"> IOException {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> doDescribe(contents) == </span><span style="color: #7f0055;"><strong>null</strong></span><span style="color: #000000;"> ? </span><span style="color: #0000c0;"><em>INVALID</em></span><span style="color: #000000;"> : </span><span style="color: #0000c0;"><em>VALID</em></span><span style="color: #000000;">;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>int</strong></span><span style="color: #000000;"> describe(InputStream contents, IContentDescription description) </span><span style="color: #7f0055;"><strong>throws</strong></span><span style="color: #000000;"> IOException {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> describe(</span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> InputStreamReader(contents), description);</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>private</strong></span><span style="color: #000000;"> String doDescribe(Reader contents) </span><span style="color: #7f0055;"><strong>throws</strong></span><span style="color: #000000;"> IOException {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; InputSource source = </span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> InputSource(contents);</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>try</strong></span><span style="color: #000000;"> {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #0000c0;">parser</span><span style="color: #000000;">.parse(source);</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; } </span><span style="color: #7f0055;"><strong>catch</strong></span><span style="color: #000000;"> (SAXException e) {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>null</strong></span><span style="color: #000000;">;</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; } </span><span style="color: #7f0055;"><strong>catch</strong></span><span style="color: #000000;"> (AcceptedException e) {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> e.</span><span style="color: #0000c0;">acceptedRootElement</span><span style="color: #000000;">;</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; } </span><span style="color: #7f0055;"><strong>catch</strong></span><span style="color: #000000;"> (RejectedException e) {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>null</strong></span><span style="color: #000000;">;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>null</strong></span><span style="color: #000000;">;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> QualifiedName[] getSupportedOptions() {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>return</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>null</strong></span><span style="color: #000000;">;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>class</strong></span><span style="color: #000000;"> RootElementParser </span><span style="color: #7f0055;"><strong>extends</strong></span><span style="color: #000000;"> SAXParser {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>void</strong></span><span style="color: #000000;"> startElement(QName qName, XMLAttributes attributes, Augmentations augmentations) </span><span style="color: #7f0055;"><strong>throws</strong></span><span style="color: #000000;"> XNIException {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>super</strong></span><span style="color: #000000;">.startElement(qName, attributes, augmentations);</span></span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>if</strong></span><span style="color: #000000;"> (</span><span style="color: #0000c0;"><em>ROOT_ELEMENT</em></span><span style="color: #000000;">.equals(qName.</span><span style="color: #0000c0;">localpart</span><span style="color: #000000;">)) {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; String namespace = </span><span style="color: #0000c0;">fNamespaceContext</span><span style="color: #000000;">.getURI(qName.</span><span style="color: #0000c0;">prefix</span><span style="color: #000000;">);</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>if</strong></span><span style="color: #000000;"> (namespace != </span><span style="color: #7f0055;"><strong>null</strong></span><span style="color: #000000;"> &amp;&amp; </span><span style="color: #0000c0;"><em>WSBPEL_2_NAMESPACE</em></span><span style="color: #000000;">.equals(namespace))</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>throw</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> AcceptedException(qName.</span><span style="color: #0000c0;">localpart</span><span style="color: #000000;">);</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>else</strong></span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>throw</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> RejectedException();</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; } </span><span style="color: #7f0055;"><strong>else</strong></span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>throw</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> RejectedException();</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160; }</span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>class</strong></span><span style="color: #000000;"> AcceptedException </span><span style="color: #7f0055;"><strong>extends</strong></span><span style="color: #000000;"> RuntimeException {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> String </span><span style="color: #0000c0;">acceptedRootElement</span><span style="color: #000000;">;</span></span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>public</strong></span><span style="color: #000000;"> AcceptedException(String acceptedRootElement) {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>this</strong></span><span style="color: #000000;">.</span><span style="color: #0000c0;">acceptedRootElement</span><span style="color: #000000;"> = acceptedRootElement;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160;&#160;&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>static</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>final</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>long</strong></span><span style="color: #000000;"> </span><span style="color: #0000c0;"><em>serialVersionUID</em></span><span style="color: #000000;"> = 1L;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p><span style="font-size: 8pt; font-family: courier new,courier; "><br/></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160; </span><span style="color: #7f0055;"><strong>private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>class</strong></span><span style="color: #000000;"> RejectedException </span><span style="color: #7f0055;"><strong>extends</strong></span><span style="color: #000000;"> RuntimeException {</span></span></p><p style="margin-bottom: 0in;"><span style="font-size: 8pt; font-family: courier new,courier; "><span style="color: #000000;">&#160;&#160;&#160; </span><span style="color: #7f0055;"><strong>private</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>static</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>final</strong></span><span style="color: #000000;"> </span><span style="color: #7f0055;"><strong>long</strong></span><span style="color: #000000;"> </span><span style="color: #0000c0;"><em>serialVersionUID</em></span><span style="color: #000000;"> = 1L;</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">&#160; }</span></p><p style="margin-bottom: 0in;"><span style="color: #000000; font-size: 8pt; font-family: courier new,courier; ">}</span></p><h1>References</h1><p><a class="jive-link-external-small" href="http://wiki.bioclipse.net/index.php?title=Contenttypes_and_describers">Contenttypes and describers</a></p><p><span style="color: #000000; font-size: 12pt; font-family: Liberation Serif,serif; "><a class="jive-link-external-small" href="http://www.developer.com/java/other/article.php/3648736/Eclipse-Tip-Define-Custom-Content-Types-to-Identify-Your-Data-Files.htm">Eclipse Tip: Define Custom Content Types to Identify Your Data Files</a></span></p><p><span style="color: #000000; font-size: 12pt; font-family: Liberation Serif,serif; "><a class="jive-link-external-small" href="http://cvalcarcel.wordpress.com/2009/10/25/writing-an-eclipse-plug-in-part-9-custom-project-defining-a-custom-file-type/">Lessons from Behind The Curtain</a></span></p><p><span style="color: #000000; font-size: 12pt; font-family: Liberation Serif,serif; "><a class="jive-link-external-small" href="http://www.eclipticalsoftware.com/emf/#contenttype">EMF Bits</a></span></p><p><span style="color: #000000; font-size: 12pt; font-family: Liberation Serif,serif; "><a class="jive-link-external-small" href="http://www.eclipsezone.com/eclipse/forums/t107605.html">Eclipse Zone</a></span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-15183">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss Tools Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2129">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>