Freigeben über


Schema.xml

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Each list definition that appears as an option on the Create page has its own Feature subfolder in Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES that includes a Schema.xml file. The Schema.xml file defines the views, forms, toolbar, and special fields for lists that are created through the list definition.

List Definition Tasks with Schema.xml

The following kinds of tasks can be performed in a Schema.xml file to customize a list definition:

  • Add custom fields built on the base field types defined in FldTypes.xml (You cannot create custom base field types.)

  • Create a custom view for lists created through the list definition

  • Specify custom form pages for working with list items

  • Specify the default description that is displayed for the list in the user interface (UI)

  • Define the Actions area that is displayed in the side navigational area of list views

Warning

Making changes to an originally installed Schema.xml file on a server running Windows SharePoint Services can break existing lists, and the changes may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version. Create a custom list definition Feature instead of modifying original schema files. For more information on the best practice to follow, see How to: Create a Custom List Definition.

File Format

List Element

The top-level List element specifies the internal name and display name for the list definition, as well as the direction of text used in lists, and the site-relative URL at which lists are created.

Note

In all the XML examples in this topic, strings that begin "$Resources" are constants defined in an .resx file in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Resources.

<List 
  xmlns:ows="Microsoft SharePoint" 
  Title="Tasks" 
  FolderCreation="FALSE" 
  Direction="$Resources:Direction;" 
  Url="Lists/Tasks" 
  BaseType="0">

Like most attributes of the List element in a Schema.xml file, specification of the site-relative URL is largely irrelevant because it is overridden by list settings in the Onet.xml file of the site definition. This element optionally specifies Microsoft SharePoint as an XML namespace. The BaseType attribute specifies a base list type that is defined within the BaseTypes element of an Onet.xml file. Use the VersioningEnabled attribute to specify whether versioning is enabled by default for document libraries created through the list definition.

MetaData Element

The MetaData element groups list metadata within the List element and may contain the following subelements.

ContentTypes Element

The ContentTypes element specifies content types to associate with lists that are created through the list definition.

<MetaData>
  <ContentTypes>
    <ContentTypeRef 
      ID="0x0108">
      <Folder 
      TargetName="Task" />
    </ContentTypeRef>
    <ContentTypeRef 
      ID="0x0120" />
  </ContentTypes>

Fields Element

The Fields element contains field definitions for special fields that may be required in a list definition.

<Fields>
  <Field 
    ID="{a8eb573e-9e11-481a-a8c9-1104a54b2fbd}" 
    Type="Choice" 
    Name="Priority" 
    DisplayName="$Resources:core,Priority;" 
    SourceID="http://schemas.microsoft.com/sharepoint/v3" 
    StaticName="Priority">
    <CHOICES>
      <CHOICE>$Resources:core,Priority_High;</CHOICE>
      <CHOICE>$Resources:core,Priority_Normal;</CHOICE>
      <CHOICE>$Resources:core,Priority_Low;</CHOICE>
    </CHOICES>
    <MAPPINGS>
      <MAPPING Value="1">$Resources:core,Priority_High;</MAPPING>
      <MAPPING Value="2">$Resources:core,Priority_Normal;</MAPPING>
      <MAPPING Value="3">$Resources:core,Priority_Low;</MAPPING>
    </MAPPINGS>
    <Default>$Resources:core,Priority_Normal;</Default>
  </Field>
  ...
  <Field 
    ID="{d2311440-1ed6-46ea-b46d-daa643dc3886}" 
    Type="Number" 
    Name="PercentComplete" 
    Percentage="TRUE" 
    Min="0" 
    Max="1" 
    DisplayName="$Resources:core,Percent_Complete;" 
    SourceID="http://schemas.microsoft.com/sharepoint/v3" 
    StaticName="PercentComplete">
  </Field>
  <Field 
    ID="{53101f38-dd2e-458c-b245-0c236cc13d1a}" 
    Type="User" 
    List="UserInfo" 
    Name="AssignedTo" 
    DisplayName="$Resources:core,Assigned_To;" 
    SourceID="http://schemas.microsoft.com/sharepoint/v3" 
    StaticName="AssignedTo">
  </Field>
  ...
</Fields>

Each Field element specifies a display name (DisplayName), an internal name (Name), a field type (Type) defined in FldTypes.xml on which the field is based, and other field properties as required.

For a programming task that shows how to add a custom field to a Schema.xml file, see How to: Create a Custom List Definition.

Views Element

The Views element contains the definitions for views that are available by default when a list is created.

<Views>
  ...
  <View 
    BaseViewID="2" 
    Type="HTML" 
    WebPartZoneID="Main" 
    DisplayName="$Resources:core,My_Tasks;" 
    MobileView="True" 
    MobileDefaultView="True" 
    SetupPath="pages\viewpage.aspx" 
    ImageUrl="/_layouts/images/issues.png" 
    Url="MyItems.aspx" 
    ReqAuth="TRUE">
    <GroupByHeader>
      ...
    <GroupByFooter>
      ...
    <ViewHeader>
      ...
    <ViewBody>
      ...
    <ViewFooter>
      ...
    <PagedRowset>
      ...
    <PagedClientCallbackRowset>
      ...
    <PagedRecurrenceRowset>
      ...
    <RowLimit
      Paged="TRUE">100</RowLimit>
    <ViewEmpty>
      ...
    <Toolbar Type="Standard" />
    <ViewFields>
      <FieldRef Name="LinkTitle" />
      <FieldRef Name="Status" /> 
      <FieldRef Name="Priority" /> 
      <FieldRef Name="DueDate" /> 
      <FieldRef Name="PercentComplete" /> 
    </ViewFields>
  <Query>
    <Where>
      <Eq>
        <FieldRef Name="AssignedTo" />
        <Value Type="Integer">
          <UserID />
        </Value>
      </Eq>
    </Where>
    <OrderBy>
      <FieldRef Name="Status" /> 
      <FieldRef Name="Priority" /> 
    </OrderBy>
  </Query>
  </View>
  ...
</Views>

Each View element specifies the type of format used in the display (usually HTML) and a unique ID for the view. When the view is displayed in a Web Part, the View element also specifies the title of the view. The Url attribute is used in list creation to specify the base name of the ASPX page in which the view is displayed. View also specifies the Web Part zone ID of the Web Part in which the view is displayed.

The View element contains subelements that define the following:

  • The various parts of a view (including the header, body, and footer)

  • The Group By section

  • A limit on the number of rows, or items, to display

  • Rowsets that define how to display items when the number exceeds the row limit

  • What to display when no items are returned in the view

  • The toolbar area that is displayed above lists

  • The fields displayed in the view

  • The query that filters the view

The Toolbar element defines the kind of toolbar that is displayed in the navigational area of the list view. Possible values include the following:

  • RelatedTasks for the Actions section that is displayed in the side navigational area of list views

  • Standard for normal views

  • Freeform for summary views on home pages

Forms Element

The Forms element contains references to the forms used when working with individual list items.

<Forms>
  <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>

Each Form element specifies the form type, which can be DisplayForm, EditForm, or NewForm, as well as the name of the ASPX page used for the form and the Web Part zone ID of the Web Part in which the form is displayed on the page.

DefaultDescription Element

A DefaultDescription element specifies the description that is displayed for the list definition in the UI.

<DefaultDescription>$Resources:core,camlidT13;</DefaultDescription>

This element is overridden by the Description attribute of the List element corresponding to the current list definition that is specified within a configuration in Onet.xml.

Important

A value for this element must be specified in custom list definitions.

See Also

Concepts

List Schema

Guidelines for Using Custom Site Definitions, Configurations, and Templates