Share via


Understanding Schema.xml Files

Applies to: SharePoint Foundation 2010

Each list definition that appears as an option on the Create page has a Schema.xml file that is located in a subfolder of %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES, or that is deployed as part of a sandboxed solution. 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

You can perform the following kinds of tasks in a Schema.xml file to customize a list definition:

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

  • Create a custom view for lists that are 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)

Warning

Making changes to an originally installed Schema.xml file on a server that is running Microsoft SharePoint Foundation can break existing lists. The changes may be overwritten when you install updates or service packs for SharePoint Foundation, 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, 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, in addition to the direction of text that is 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 with "$Resources" are constants defined in a .resx file in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\Resources.

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

Like most attributes of the List element in Schema.xml, 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 that are 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" />
    <ContentTypeRef ID="0x012004" />
  </ContentTypes>

Fields Element

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

<Fields>
  <Field 
    ID="{c3a92d97-2b77-4a25-9698-3ab54874bc6f}" 
    Name="Predecessors" 
    Type="LookupMulti" 
    Mult="TRUE" 
    Required="FALSE" 
    DisplayName="$Resources:core,Tasks_Predecessors;" 
    StaticName="Predecessors" 
    List="Self" 
    ShowField="Title" 
    DisplaceOnUpgrade="TRUE" 
    SourceID="https://schemas.microsoft.com/sharepoint/v3">
  </Field>
  <Field 
    ID="{a8eb573e-9e11-481a-a8c9-1104a54b2fbd}" 
    Type="Choice" 
    Name="Priority" 
    DisplayName="$Resources:core,Priority;" 
    SourceID="https://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="https://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="https://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), and other field properties as required, that are defined in the FldTypes.xml file on which the field is based.

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.

Note

SharePoint Foundation 2010 uses XSLT to define list views, and the View schema is maintained for backward compatibility. For information about XSLT list views, see List Views.

<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">
  <XslLink Default="TRUE">main.xsl</XslLink>
  <RowLimit Paged="TRUE">30</RowLimit>
  <Toolbar Type="Standard" />
  <ViewFields>
    <FieldRef Name="LinkTitle"></FieldRef>
    <FieldRef Name="Status"></FieldRef>
    <FieldRef Name="Priority"></FieldRef>
    <FieldRef Name="DueDate"></FieldRef>
    <FieldRef Name="PercentComplete"></FieldRef>
  </ViewFields>
  <ParameterBindings>
    <ParameterBinding 
      Name="NoAnnouncements" 
      Location="Resource(wss,noXinviewofY_LIST)" />
    <ParameterBinding 
        Name="NoAnnouncementsHowTo" 
        Location="Resource(wss,noXinviewofY_DEFAULT)" />
  </ParameterBindings>
  <Query>
    <Where>
      <Eq>
        <FieldRef Name="AssignedTo"></FieldRef>
        <Value Type="Integer">
          <UserID />
        </Value>
      </Eq>
    </Where>
    <OrderBy>
      <FieldRef Name="Status"></FieldRef>
      <FieldRef Name="Priority"></FieldRef>
    </OrderBy>
  </Query>
</View>
  ...
</Views>

Each View element specifies the type of format that is 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.

In SharePoint Foundation, the View element contains subelements that define various parts of a view:

  • The Aggregations element defines field references for calculated columns.

  • The XslLink element specifies an XSL file that defines the various parts of a view, including, for example, the header, body, and footer. It also defines the group-by sections, the rowsets that define how to display items when the number exceeds the row limit, and the view empty sections.

  • The RowLimit element specifies a limit on the number of rows, or items, to display.

  • The Toolbar element defines the area that is displayed above lists.

  • The ViewFields element specifies fields that are displayed in the view.

  • The ParameterBindings element specifies resource strings for implementation in XSLT. For more information, see XSLT Parameter Bindings.

  • The Query element defines a filter for the view.

Forms Element

The Forms element contains references to the forms that are used when users are 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, and also the name of the ASPX page that is 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 that corresponds 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.

List Templates

Users create custom list templates on the Save as Template page for a list, or through code that uses the SaveAsTemplate method of the Microsoft.SharePoint.SPList class. When saved, a list template is stored as an .stp file in the List Template gallery of the top-level site in a site collection. List templates are available to all sites in the site collection that derive from the same site definition and language as the site on which the list was originally created. To make a list template available to a site in another site collection, download the template from its current gallery and then upload it to the gallery of the new site collection.

See Also

Concepts

List Schema

List Instance

Site Types: WebTemplates and Site Definitions

Other Resources

List Views