Friday, July 27, 2007

Element.xml explained

Some xml elements in Element.xml file in WSS 3.0:

1. Root element: Elements. It contains a Id attribute, which is a guid to uniquely identify this element.

2. Receivers element: This element is inside Elements. It contains ListTemplateId attribute which specifies what type of list will be attached to list item event handler. For example, a value of 101 means that the event handler will be attached to all document libraries.

3. Receiver element: This element is inside Receivers element. It contains several sub elements in it to define the class to receive list item event. A sample configure is like this:

<name>DigiDoc signature check event
<assembly>wssDigiDoc, Version=, Culture=neutral, PublicKeyToken=44b3223b8da05605

  • Name: A descriptive name
  • Type: The event type that this receiver class will handle. The possible values are: ItemAdd, ItemUpdate, ItemDelete...
  • SequenceNumber: It specifies the event firing order, if multiple event handlers are associated with the feature
  • Assembly: Fully qualified assembly name
  • Class: Class in the assembly that handles item level event
4. CustomAction: This defines the actions that are related to the feature
<customaction id="DigiDocSettings" groupid="SiteAdministration" location="Microsoft.SharePoint.SiteSettings" rights="ManageWeb" sequence="30" title="DigiDoc feature settings">
<urlaction url="_layouts/ddocsetting.aspx"></urlaction>
  • Id: The unique identifier for the custom action
  • GroupId: See Location attribute.
  • Location: This combined with GroupId defines where to put the action link. The possible value for Location are:
  1. Microsoft.SharePoint.SiteSettings, the site settings page. The GroupId then defines the which section in site settings page the action link should be put under. GroupId SiteAdministration will put the action link under "Site Administration" section on site settings page; GroupId SiteCollectionAdministration will put the action link under "Site Collection Administration" section; GroupId UsersAndPermissions refers to Users and Permissions section, etc.
  2. Microsoft.SharePoint.StandarMenu. The SharePoint standard menu. The GroupId can be: SiteActions, which means to put the action link in SiteActions menu on top right of page; SettingsMenu, which means the list's settings menu; ActionsMenu, which means the list's actions menu; NewMenu, which means the list's New menu; PersonalActions which means "Welcome (username)" menu on top of page.
  3. Microsoft.SharePoint.Administration.Operations: Operations tab in WSS central administration. The GroupId is GUID referencing the Id defined in CustomActionGroup. The Title attribute determines the text appearing as the link.
  4. Microsoft.SharePoint.Administration.ApplicationManagement: Application tabl in WSS central administration. The GroupId is GUID referencing the Id defined in CustomActionGroup. The Title attribute determines the text appearing as the link.
  5. EditControlBlock: The context menu when you move your mouse on list item. When the location is set to this value, you need to also to set RegistrationType and RegistrationId attribute to specify what type of list to apply the custom action.
<Elements xmlns="">
Title="View Unified Logging Service"
Description="Displays Unified Logging Service (ULS) logs.">
<UrlAction Url="_admin/ULSLogViewer.aspx"/>
  • RegistrationType: Defines what type of data this custom action applying to. The possible value could be: List, ContentType, FileType and ProgId.
  • RegistrationId: When the RegistrationType is List, this RegistrationId specifies the types of list, for example, 101 mean document library, 104 means announcement; when the RegistrationType is FileType, the RegistrationId is the file name extension.
  • Rights: Specifies a set of rights that the user must have in order for the link to be visible, for example, "ViewListItems,ManageAlerts". If not specified, then the action always appears in the list of actions. To specify multiple rights, separate the values by using commas. The set of rights are grouped logically according to AND logic, which means that a user must have all the specified rights to see an action. For a list of possible values, see Microsoft.SharePoint.SPBasePermissions.
  • Sequence: Determine the display order of the action
5. Module: This element and File element (described below) are used to provision aspx files into SharePoint site. The Url attribute of Module element defines the root URL for all the files included in this module.

6. File: This element provisions the aspx file into SharePoint site. The Url attribute references the physical file deployed. The Name attribute defines the file name used by user. Type attribute specifies if this file is customizable. For example:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
<Module Url="Pages">
<File Url="ViewLog.aspx" Name=ViewClientLog.aspx Type="Ghostable" />

The above element.xml will provision ViewLog.aspx file into SharePoint site. User should be able to access the file using http:///Pages/ViewClientLog.aspx

7. Field: The Field element defines the site columns that can be used in creating new column in list. The field definition schema is much same as the definition in list schema.xml file.
<field name="Digital Signers" id="{6251682B-A4A6-4cc4-BCE4-7C5247546CCD}" type="Note" title="Digital Signers" displayname="Digital Signers" description="Names of people who have signed this document digitally. Automatically updated" readonly="FALSE" showineditform="FALSE" showinfiledlg="FALSE" showinnewform="FALSE">
To use the field defined in element.xml file, use the following code snippet:
if (SPContext.Current.Web.Fields.ContainsField("MyFieldTitle"))
SPField field = web.Fields.GetField("MyFieldTitle");

if (!item.Fields.ContainsField(

No comments: