Friday, November 14, 2008

Collabarative Application Markup Language (CAML)

CAML (Collaborative Application Markup Language) is an XML based markup language used with the family of Microsoft SharePoint technologies (Windows Sharepoint Services and Office SharePoint Server). Unlike plain XML, CAML contains specific groups of tags to both define and display (render) data.

CAML allows developers to both construct and display data. Microsoft refers to elements used to display data as "Rendering" elements.

In general, most of all xml files in a sharepoint installation include CAML. Specifically CAML is very important in site and list definitions, via the Onet.xml files as well as other corresponding xml files. Here the CAML is used to define what elements exist on an instance of a site, and the display of these sub-elements, while the aspx files are used to define how to arrange and display those elements to form the site.
CAML is also used to query against Sharepoint lists and views, when programming against the SharePoint API.

CAML can be used to do the following:

1. Provide schema definition to the Web site provisioning system about how the site looks and acts.
2. Define views and forms for data and page rendering or execution.
3. Act as a rendering language that performs functions in the DLL like pulling a value from a particular field.
4. Provide batch functionality for posting multiple commands to the server using protocol.

Why would you use CAML as opposed to just using Microsoft FrontPage® or other editing tools?

1. To make universal changes, such as adding a new logo to the main pages of every site you create.
2. To define a content type, such as for adding Flash movies to the SharePoint team Web site.
3. It provides the ultimate in customization and flexibility; manipulating CAML allows you total control over the site provisioning system, for instance, when creating a list or adding a view.

CAML Queries:

CAML can be used to query data from various lists. See the below example...

SPWeb web = SPControl.GetContextWeb(this.Context);
SPView view = web.Lists["List Name"].Views["Search"];

// create a List View called "Search"

// Get
string query = view.Query;

// Set
view.Query = query;
view.Update();

String query = "";

// Some of other query conditions
query += ""; // Condtion
query += ""; // Operator
query += ""; // Field Name
query += "a"; // Value
query += "
"; // Close tags

-------------------------------------------------------------------
Resources : Google Search

No comments: