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
-
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?)>
<!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>
- 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
<!ELEMENT describer (parameter*)>
<!ATTLIST describer
class CDATA #REQUIRED>
- 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
<!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 application class
- value - the value of this parameter made available to instances of the specified application class
Examples:
Following is an example of a XML-based content type declaration using the 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"
>
<param 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>
In a case like the example above, when we are just trying to associate new file names/extensions to an existing content type, to contribute a file association is usually the best thing to do:
<extension point=
"org.eclipse.core.runtime.contentTypes"
>
<file-association
content-type=
"org.eclipse.core.runtime.text"
file-extensions=
"mytxt"
/>
</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.
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 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Common Public License v1.0 which
accompanies
this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html