Personal Web & Sample Site
Skip Navigation Links
HOME |
About Me |
Articles
| Contact Us
CAML
Rating: 8 user(s) have rated this article Average rating: 5.0
Posted by: joet, on 2/15/2009, in category "XML"
Views: this article has been read 3144 times
Location: Houston, Tx, United States
Abstract: 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 (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.

In general, almost all xml files in a sharepoint installation utilize 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 can be used by Software Developers to query against Sharepoint lists and views, when programming against the SharePoint API (CAML is supported by Sharepoint Web Services and by the Sharepoint Object Model).

CAML query syntax can be created graphically from an existing Sharepoint list by using the U2U CAML Generator tool.

CAML is used for two types of rendering in Windows SharePoint Services: to define the type of data that is contained within a field, and to construct HTML that is displayed in the browser.

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

  <Fields>
    <Field Type="Counter" Name="ID"/>
    . . . other field definitions. . .
  </Fields>

CAML allows for the generation of HTML based on specific sets of tags. For example, the following example loops through some data and generates an HTML drop down menu of choices:

 <ForEach Select="CHOICES/CHOICE">
    <HTML>fld.AddChoice(</HTML>
    <ScriptQuote>
       <Property Select="."/>
    </ScriptQuote>
    <HTML>, </HTML>
    <ScriptQuote>
       <Property Select="Value"/>
    </ScriptQuote>
    <HTML>);</HTML>
  </ForEach>

CAML is also used to define tables in the Windows SharePoint Services database during site provisioning. So, you need to be familliar with this language but if you've worked with XML, this should come easy.

Back in the day we didn't have any tools to help us write queries for search or XML for BDC connections. Now, I'm happy to report that there is a tool called U2U CAML Query Builder that works great for creating CAML queries on the fly for your code. Here is the link to U2U's web site where you can download the tool. If you're working in SharePoint 2010 not to worry, it works just fine in SharePoint 2010. I've been using it less and less because I'm writing more queries with C# LINQ.

 

 


How would you rate this article?

User Feedback

Post your comment
Name:
E-mail:
Comment:
Insert Cancel

Copyright © 2013 Jose M. Tamez
Last Updated August 18th 2013