Content Types
Identifier:
org.eclipse.core.contenttype.contentTypes
Since:
3.2
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
>
<!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.XMLRootElementContentDescriber2
,
a built-in describer:
<extension point=
"org.eclipse.core.contenttype.contentTypes"
>
<content-type id=
"ABC"
base-type=
"org.eclipse.core.runtime.xml"
file-extensions=
"a,b,c"
>
<describer class=
"org.eclipse.core.runtime.content.XMLRootElementContentDescriber2"
>
<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.contenttype.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.contenttype.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.contenttype.contentTypes"
>
<content-type id=
"MyContentType"
file-extensions=
"dat"
>
<property name=
"file-format"
value=
"1"
/>
</content-type>
</extension>
Supplied Implementation:
The org.eclipse.core.contenttype 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.contenttype plug-in provides ready-to-use implementations of content describers:
- org.eclipse.core.runtime.content.XMLRootElementContentDescriber2
- org.eclipse.core.runtime.content.BinarySignatureDescriber
Copyright (c) 2004, 2008 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
https://www.eclipse.org/legal/epl-v10.html