Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Server Technologies
SDK Documentation
General Reference
Feature Schemas
 ContentType Element (ContentType)
ContentType Element (ContentType)

Defines a single content type.

<ContentType
  BaseType="Text"
  ID="Text"
  Name="Text"
  Group="Text"
  DocumentTemplate="Text"
  ResourceFolder="Text"
  ReadOnly="TRUE" | "FALSE"
  Hidden="TRUE" | "FALSE"
  Description="Text"
  Sealed="TRUE" | "FALSE"
  V2ListTemplateName="Text"
  Version="Integer"
  FeatureId="Text">
</ContentTypes>
Attribute Description

BaseType

Reserved for internal use.

ID

Required Text. Specifies the content type ID of the content type.

Name

Required Text. Specifies the content type name.

Group

Optional Text. Specifies the content type group to which the content type is assigned. Content type groups are user-defined groups that help you organize your columns into logical categories.

DocumentTemplate

Obsolete.

ResourceFolder

Obsolete.

ReadOnly

Optional Boolean. TRUE to define the content type as read-only.

If you do not include this attribute, Windows SharePoint Services treats the content type as if this attributes was set to FALSE.

Hidden

Optional Boolean. TRUE to define the content type as hidden. If you define a content type as hidden, Windows SharePoint Services does not display that content type on the New button in list views.

If you do not include this attribute, Windows SharePoint Services treats the content type as if this attributes was set to FALSE.

Description

Optional Text. Provides a description for the content type, to display in the Windows SharePoint Services user interface.

Sealed

Optional Boolean. TRUE to define the content type as sealed. You must have site collection administrator rights to unseal and edit a content type defined as sealed.

If you do not include this attribute, Windows SharePoint Services treats the content type as if this attributes was set to FALSE.

V2ListTemplateName

Optional Text. Specifies the Windows SharePoint Services 2.0 list template type to which this content type maps. For example, the Document content type maps to the Document Library list template.

Version

Reserved for future use.

FeatureId

Optional Text. Provides the ID of the feature in which the content type is packaged.

For more information about content types, see Content Types.

For more information about assigning content type IDs, see Content Type IDs.

For more information about read-only and sealed content types, see Content Type Change Control.

For more information about hidden content types, see Content Type Access Control.

The following example is the content type definition of the Document content type. The example has been edited for clarity.

Xml
<ContentType ID="0x0101"
  Name="$Resources:Document"
  Group="$Resources:Document_Content_Types"
  Description="$Resources:DocumentCTDesc"
  V2ListTemplateName="doclib"
  Version="0">
  <FieldRefs>
    <RemoveFieldRef ID=FID_Attachments Name="Attachments" /> <!-- Attachments -->
    <RemoveFieldRef ID=FID_WorkflowVersion Name="WorkflowVersion" /> <!-- WorkflowVersion -->
…
    <FieldRef ID=FID_SelectFilename Name="SelectFilename" /> <!-- SelectFilename -->
    <FieldRef ID=FID_FileLeafRef Name="FileLeafRef" Required="TRUE"/> <!-- FileLeafRef -->
    <FieldRef ID=FID_Created Name="Created" Hidden="TRUE" /> <!-- Created -->
    <FieldRef ID=FID_Title Name="Title" Required="FALSE" ShowInNewForm="FALSE" ShowInEditForm="TRUE"/> <!-- Title --></FieldRefs>
  <XmlDocuments>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
      <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
        <Display>DocumentLibraryForm</Display>
        <Edit>DocumentLibraryForm</Edit>
        <New>DocumentLibraryForm</New>
      </FormTemplates>
    </XmlDocument>
  </XmlDocuments>
</ContentType>
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Content Type ID attribute need clarification      Doc WattsMan   |   Edit   |  
You need some documentation here for the ID attribute. It's much more complicated than just a simple GUID. It has a complicated format that includes embedded information about content type inheritance. I wrote up my findings and posted them here: http://thomascarpe.com/Lists/Posts/Post.aspx?ID=31
FieldRefs tag is mandatory      Wosfilm   |   Edit   |  
I found out that the <FieldRefs> tag seems to be mandatory to make sure the content type will inherit fields correctly. E.g. if you create a content type that inherits from the Document content type and don't include the <FieldRefs> tag, event if it's empty, the new content type will only contain fields that are explicitly defined in the Document content type and not the Title field declared in the Item content type, which the Document content type inherits from.
Tags What's this?: Add a tag
Flag as ContentBug
Name attribute's value cannot contain some special characters!      M. Blumenthal   |   Edit   |  

The Name attribute's value cannot contain any colons (":") or commas (","). There may be other special characters that it doesn't like either.

If you put one of these characters in the value of the Name attribute (for example, "My workflow: Task 1 Content type"), the content type will not be deployed during feature activation. If you have verbose logging turned on for the "Feature Infrastructure" logging group, you will get an error message in the ULS log, but STSADM WILL NOT REPORT THE ERROR. The error (Windows SharePoint Services, General, Unexpected) in the ULS log is:
SPContentTypeElement.ElementActivated() Skipped activation because of InvalidName: '<your content type name here>'

If you find other special characters that cause this, please add that information to this post!

I've posted some background to this issue on my blog: http://blumenthalit.net/blog/Lists/Posts/Post.aspx?ID=49

Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker