#
Content Types

###### Identifier:

org.eclipse.core.runtime.contentTypes

###### Since:

3.0

###### Description:

The content types extension point allows plug-ins to contribute to the platform content type catalog. There are two forms of contributions: content types and file associations.

- a content type represents a file format and its naming conventions. Content types can be defined from scratch, or can inherit from existing ones, specializing them. Also, a content type can be made into an alias for another content type (see the `alias-for` attribute). When this feature is used:
  - if the target is absent, the alias content type is processed as a normal content type;
  - if the target is present, all references to the alias type are automatically transformed into references to the target type, and the alias type cannot be accessed nor is exposed through the API.
- a file association extends an existing content type by associating new file names and/or extensions to it

###### Configuration Markup:

<!ELEMENT extension (content-type* , file-association*)>

<!ATTLIST extension

point CDATA #REQUIRED

id CDATA #IMPLIED

name CDATA #IMPLIED>

- point - a fully qualified identifier of the target extension point
- id - an optional identifier of the extension instance
- name - an optional name of the extension instance

<!ELEMENT content-type (describer? , property*)>

<!ATTLIST content-type

id CDATA #REQUIRED

base-type CDATA #IMPLIED

name CDATA #REQUIRED

file-extensions CDATA #IMPLIED

file-names CDATA #IMPLIED

priority (low|normal|high) "normal"

default-charset CDATA #IMPLIED

describer CDATA #IMPLIED

alias-for CDATA #IMPLIED>

- id - the identifier for this content type (simple id token, unique for content types within the extension namespace). The token cannot contain dot (.) or whitespace
- base-type - the fully qualified identifier of this content type's base type. This content type will inherit its base type's file associations, content describer and default charset, unless they are redefined
- name - the human-readable name of this content type
- file-extensions - a comma-separated list of file extensions to be associated with this content type
- file-names - a comma-separated list of file names to be associated with this content type
- priority - the priority for this content type. Priorities are used to solve conflicts (when two content types are associated to the same file name/extension)
- default-charset - the default charset for this content type, or an empty string, if this content type should not have a default charset even if the parent has one. This is a convenience attribute, equivalent to specifying:

        <content-type>
          <property name="org.eclipse.core.runtime.charset" default="charset-name"/>
        </content-type>

- describer - the fully qualified name of a class that implements `org.eclipse.core.runtime.content.IContentDescriber` or `org.eclipse.core.runtime.content.ITextContentDescriber`, or an empty string, if this content type should not have a describer even if the parent has one
- alias-for - the fully qualified identifier of the content type this content type is an alias for

<!ELEMENT describer (parameter*)>

<!ATTLIST describer

class CDATA #REQUIRED

plugin CDATA #IMPLIED>

If the describer attribute is used in the content-type element, this element is ignored.

- class - the fully qualified name of a class that implements `org.eclipse.core.runtime.content.IContentDescriber` or `org.eclipse.core.runtime.content.ITextContentDescriber`, or an empty string, if this content type should not have a describer even if the parent has one
- plugin - the id for the plug-in providing the describer class

<!ELEMENT file-association EMPTY>

<!ATTLIST file-association

content-type CDATA #REQUIRED

file-names CDATA #IMPLIED

file-extensions CDATA #IMPLIED>

- content-type - the fully qualified identifier for the content type this file association contributes to
- file-names - a comma-separated list of file names to be associated with the target content type
- file-extensions - a comma-separated list of file extensions to be associated with the target content type

<!ELEMENT parameter EMPTY>

<!ATTLIST parameter

name CDATA #REQUIRED

value CDATA #REQUIRED>

- name - the name of this parameter made available to instances of the specified content describer class
- value - an arbitrary value associated with the given name and made available to instances of the specified content describer class

<!ELEMENT property EMPTY>

<!ATTLIST property

name CDATA #REQUIRED

default CDATA #IMPLIED>

Declares a property related to this content type, optionally assigning a default value. See `org.eclipse.core.runtime.content.IContentDescription` for more information on properties.

- name - the name of the property. If the property is being overriden and has been originally defined in a different namespace, a fully qualified property name must be used
- default - the default value of the property, or an empty string, if this content type should not have a default value for this property even if a parent has one

###### Examples:

Following is an example of a XML-based content type declaration using `org.eclipse.core.runtime.content.XMLRootElementContentDescriber`, a built-in describer:

       <extension point="org.eclipse.core.runtime.contentTypes">
          <content-type id="ABC"
           base-type="org.eclipse.core.runtime.xml"
           file-extensions="a,b,c">
           <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber">
            <parameter name="element" value="abc"/>
           </describer>
          </content-type>
       </extension>

Here is an example of a simple text-based content type that has a specific file extension:

       <extension point="org.eclipse.core.runtime.contentTypes">
          <content-type id="MyText"
           base-type="org.eclipse.core.runtime.text"
           file-extensions="mytxt"/>
       </extension>

When there is need to associate new file names/extensions to an existing content type (as opposed to defining a new content type), a plug-in can contribute a file association as seen below. This has the effect of enhancing the definition of the text content type to include files with names following the "*.mytxt" pattern.

       <extension point="org.eclipse.core.runtime.contentTypes">
          <file-association
           content-type="org.eclipse.core.runtime.text"
           file-extensions="mytxt"/>
       </extension>

Here is an example of a content type that defines properties:

       <extension point="org.eclipse.core.runtime.contentTypes">
          <content-type id="MyContentType"
           file-extensions="dat">
             <property name="file-format" value="1"/>
          </content-type>
       </extension>

###### API Information:

The value of the class attribute in the describer element must represent an implementor of `org.eclipse.core.runtime.content.IContentDescriber` or `org.eclipse.core.runtime.content.ITextContentDescriber`. `org.eclipse.core.runtime.content.IContentDescription` objects returned by the `org.eclipse.core.runtime.content` API

###### Supplied Implementation:

The org.eclipse.core.runtime plug-in provides the following content types:

- org.eclipse.core.runtime.text
- org.eclipse.core.runtime.xml

Other plug-ins in the platform contribute other content types.

Also, the org.eclipse.core.runtime plug-in provides ready-to-use implementations of content describers:

- org.eclipse.core.runtime.content.XMLRootElementContentDescriber
- org.eclipse.core.runtime.content.BinarySignatureDescriber

Copyright (c) 2004, 2005 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html