alias-for
属性)。使用此功能时:<!ELEMENT extension (content-type* , file-association*)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED>
<!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>
<content-type>
<property name=
"org.eclipse.core.runtime.charset"
default=
"charset-name"
/>
</content-type>
<!ELEMENT describer (parameter*)>
<!ATTLIST describer
class CDATA #REQUIRED
plugin CDATA #IMPLIED>
如果在内容类型元素中使用了描述器属性,将忽略此元素。
<!ELEMENT file-association EMPTY>
<!ATTLIST file-association
content-type CDATA #REQUIRED
file-names CDATA #IMPLIED
file-extensions CDATA #IMPLIED>
<!ELEMENT parameter EMPTY>
<!ATTLIST parameter
name CDATA #REQUIRED
value CDATA #REQUIRED>
<!ELEMENT property EMPTY>
<!ATTLIST property
name CDATA #REQUIRED
default CDATA #IMPLIED>
声明与此内容类型相关的属性,可以有选择地指定缺省值。有关属性的更多信息,请参阅 org.eclipse.core.runtime.content.IContentDescription。
org.eclipse.core.runtime.content.XMLRootElementContentDescriber
(这是一个内置描述器)的基于 XML 的内容类型声明的示例:
以下是具有特定文件扩展名的基于文本的简单内容类型:<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>
当需要将新文件名/扩展与现有内容类型(与定义新内容类型相反)相关联时,插件可以提供文件关联,如下所示。这可以增强文本内容类型的定义以包括其名称遵循“*.mytxt”模式的文件。<extension point=
"org.eclipse.core.runtime.contentTypes"
>
<content-type id=
"MyText"
base-type=
"org.eclipse.core.runtime.text"
file-extensions=
"mytxt"
/>
</extension>
以下是一个定义了一些属性的内容类型的示例:<extension point=
"org.eclipse.core.runtime.contentTypes"
>
<file-association content-type=
"org.eclipse.core.runtime.text"
file-extensions=
"mytxt"
/>
</extension>
<extension point=
"org.eclipse.core.runtime.contentTypes"
>
<content-type id=
"MyContentType"
file-extensions=
"dat"
>
<property name=
"file-format"
value=
"1"
/>
</content-type>
</extension>
org.eclipse.core.runtime 插件提供了下列内容类型:
另外,org.eclipse.core.runtime 插件提供了内容描述器的随时都可以使用的实现:
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