Provisioning Content Types in List Schemas

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

In Microsoft Windows SharePoint Services (version 3), the list schema has been updated to enable you to specify the content types you want to provision by default on a list. These content types may be defined elsewhere, or you can define list-specific content types directly in the list schema XML.

A new element, ContentTypes, has been added to the list schema. The top-level elements of the list schema are now as follows:

<List>
  <Metadata>
    <ContentTypes>
      <ContentTypeRef ID="content type id"/>
      <Content Type>
      ...
      </Content Type>
    <Fields>
    ...
    </Fields>
  </Metadata>
<List>

Use the ContentTypeRef element to reference a content type that is defined elsewhere. The ContentTypeRef element contains one attribute, ID, which represents the content type ID of the content type to be copied locally as a list content type on this list. The site content type you reference must be in scope for the list, that is, it must be declared at the same site level or higher in the site hierarchy.

For more information on content type scope, see Content Type Scope.

Use the ContentType element to define a list content type directly on the list. The elements of the ContentType are the same as the content type definition schema.

For more information, see Content Type Definition Schema.

The list schema for Microsoft Windows SharePoint Services (version 3) includes an element tag that specifies whether the list supports multiple content types. This element must be set to true for multiple content types to be provisioned on the list.

Note

When Microsoft Windows SharePoint Services (version 3) provisions a list, it provisions only those columns declared in the base type schema of the list or in the list schema. If you reference a content type template in the list schema, and that content type references site columns are not included in the base type schema of the list or in the list schema, those columns are not provisioned on the list. You must also include those columns in the list schema for Microsoft Windows SharePoint Services (version 3) to provision them on the list.

For more information on site columns, see Introduction to Site Columns.

Programmatically Provisioning Content Types to a List

When you add a content type to a list using the Microsoft Windows SharePoint Services (version 3) object model, Microsoft Windows SharePoint Services (version 3) automatically adds any columns that content type contains that are not already on the list. This is in contrast to provisioning a list schema with content types, in which case you must explicitly add the columns to the list schema XML for Microsoft Windows SharePoint Services (version 3) to provision them.

In practical terms, this means you can easily create a list template containing all the necessary columns for the selected content types by performing the following steps:

  1. Create a blank list.

  2. Add the desired content types by using either the object model or the Microsoft Windows SharePoint Services (version 3) user interface.

  3. Save the list as a template.

To add a content type to a list, use the SPList.ContentTypes.Add method.

See Also

Concepts

Introduction to Content Types
Site and List Content Types
Content Type Scope
Content Type Object Overview