When you are building a DVWP in SharePoint, there are some project (Web site) and list properties that are available to you directly from CAML that aren’t well-documented, which you can use if you request them directly. For instance, if you add the following to your CAML <ListProperty Name=”Title” /><ProjectProperty Name=”Title” />, the titles of the project and list are available to you:
<xsl:value-of select=”@ListProperty.Title” />
<xsl:value-of select=”@ProjectProperty.Title” />
These properties are especially useful when you build CrossList DVWPs in order to build up links to items and to display information about them on the page.
Here’s an actual example from a project I worked on:
<View><Webs Scope="SiteCollection"></Webs><Lists ServerTemplate="104"></Lists><Query/><ViewFields><ProjectProperty Name="Title"/><FieldRef Name="ID"/><FieldRef Name="Title"/><FieldRef Name="Body"/><FieldRef Name="FileDirRef"/><FieldRef Name="Created"/><FieldRef Name="Author"/><FieldRef Name="Expires"/><FieldRef Name="PermMask"/><FieldRef Name="ShowOnRootPage"/></ViewFields></View>
and again in “English”:
<View>
<Webs Scope="SiteCollection"></Webs>
<Lists ServerTemplate="104"></Lists>
<Query/>
<ViewFields>
<ProjectProperty Name="Title"/>
<FieldRef Name="ID"/>
<FieldRef Name="Title"/>
<FieldRef Name="Body"/>
<FieldRef Name="FileDirRef"/>
<FieldRef Name="Created"/>
<FieldRef Name="Author"/>
<FieldRef Name="Expires"/>
<FieldRef Name="PermMask"/>
<FieldRef Name="ShowOnRootPage"/>
</ViewFields>
</View>
ProjectProperty.Property Value
A string that contains the name of a project property listed in the following table.
| Name | Value |
| BlogCategoryTitle | Category of the current post item. |
| BlogPostTitle | Title of the current post item. |
| Description | Description of the current Web site. |
| RecycleBinEnabled | 1 if the recycle bin is enabled; otherwise, 0. |
| SiteOwnerName | User name of the owner for the current site collection. |
| SiteUrl | Full URL of the current site collection. |
| Title | Title of the current Web site. |
| Url | Full URL of the current Web site. |
See ProjectProperty.Property Property for the original MSDN article.
ListProperty.Property Value
A string that contains the name of a property listed in the following table.
| Name | Value |
| Created | Date and time the list was created. |
| DefaultViewUrl | Server-relative URL of the default list view. |
| Description | Description of the list. |
| EnableSyndication | true if RSS syndication is enabled for the list; otherwise, false. |
| ItemCount | Number of items in the list. |
| LinkTitle | Title linked to list. |
| MajorVersionLimit | For a document library that uses version control with major versions only, maximum number of major versions allowed for items. |
| MajorWithMinorVersionsLimit | For a document library that uses version control with both major and minor versions, maximum number of major versions allowed for items. |
| RelativeFolderPath | Site-relative URL for the list. |
| Title | Title of the list. |
| ViewSelector | View selector with links to views for the list. |
See ListProperty.Property Property for the original MSDN article.




25 comments
Skip to comment form ↓
Paul Grafelman
September 19, 2009 at 11:51 am (UTC -4) Link to this comment
Can you post an example showing where in the CAML these additional references would go? I placed them in the ViewFields but it did not work there.
Marc
September 20, 2009 at 10:33 pm (UTC -4) Link to this comment
Paul:
You were doing the right thing putting the references into the Viewfields section. I’ve added an example above.
M.
Nick Hadlee
March 17, 2010 at 11:19 pm (UTC -4) Link to this comment
Another gem!
Marc
March 17, 2010 at 11:29 pm (UTC -4) Link to this comment
Thanks, Nick. This one’s laid fallow for a long time. Just tweeted it into the light of day again.
M.
David McElroy
March 19, 2010 at 12:42 pm (UTC -4) Link to this comment
Hi Marc
Great bit of info again! I have a DVWP that will display all documents from the site it sits on and below. It will show the ProjectProperty.Title but the ProjectProperty.Url is empty.
Its CrossList and the Scope is Recursive. Any ideas?
Marc
March 19, 2010 at 12:45 pm (UTC -4) Link to this comment
David:
Make sure that you have each property explicitly in the section.
M.
David McElroy
March 19, 2010 at 1:16 pm (UTC -4) Link to this comment
Each property (Title and Url) is specified in the CAML selectcommand.
gives the title
is empty (as is SiteUrl)
David
Marc
March 19, 2010 at 3:26 pm (UTC -4) Link to this comment
David:
Hmm. Not sure that I’ve used the URL property. You could also get at it by using ddwrt:UrlDirName on @FileRef. Check my article on EndUserSharePoint. com for some details on this.
M.
David McElroy
March 19, 2010 at 1:18 pm (UTC -4) Link to this comment
It stripped out my xsl
<xsl:value-of select="@ProjectProperty.Title" /> – gives the title
<xsl:value-of select="@ProjectProperty.Url" /> – is empty
Jasper Siegmund
October 5, 2010 at 7:49 am (UTC -4) Link to this comment
Can these properties also be used in the where clause? I tried but I can’t seem to get it working.
Marc
October 5, 2010 at 11:36 pm (UTC -4) Link to this comment
Jasper:
I just tried to use the ProjectProperty.Title in the Where clause, and I’m not having any luck, either. What are you trying to filter on? There’s probably another viable approach.
M.
Jasper Siegmund
October 6, 2010 at 2:31 am (UTC -4) Link to this comment
Hi Marc,
I need to filter CAML results based on the site title. We’ve got several seperate sites setup for customers. I’ve created a Silverlight webpart which uses a webservice to get all unfinished tasks rolled up from all customer sites. I want to be able to filter those based on the customer name which is in the sitename. I can’t use the URL because that only contains the numeric customer code, not the name. Any ideas?
Marc
October 7, 2010 at 8:52 pm (UTC -4) Link to this comment
Jasper:
What Web Service are you calling? Lists.asmx? If you’re using the Web Service, can’t you just filter in your Silverlight code?
M.
Jasper Siegmund
October 8, 2010 at 3:57 am (UTC -4) Link to this comment
Hi Marc,
I’m using a custom build web service which executes a SPSiteDataQuery. Of course I can filter out data based on other things, but I want to make sure SPSiteDataQuery keeps performing. And when I first fetch a result set of say 1000 records whilst only needing 25 of those, that will affect performance. So I was hoping I could let SPSiteDataQuery do all the filtering, but I guess that might not be possible.
Marc
October 8, 2010 at 7:10 am (UTC -4) Link to this comment
Got it. I was trying the CAML in a DVWP, so the behavior/effect there might be totally different. So you’re talking about the SiteData Web Service?
M.
Jasper Siegmund
October 8, 2010 at 12:44 pm (UTC -4) Link to this comment
Hi Marc,
No, I’m not using an OOTB webservice. I use a custom webservice which I wrote and deployed as a solution. In this webservice, there is a method which uses the SPSiteDataQuery object to query all SharePoint lists on the site (and subsites) at once.
Because there will be many subsites with many lists and even more items, I need the service to perform at its best.
Marc
October 9, 2010 at 11:53 pm (UTC -4) Link to this comment
I think you’d be much better off using Webs.GetAllSubWebCollection, filtering those results for your customer name in the Title, and then going from there. That’s going to be far more efficient. You’ll never grab any items or lists from any sites which are outside your intended targets. I’m not sure that you need to write a custom Web Service at all.
M.
Jasper Siegmund
October 10, 2010 at 7:11 am (UTC -4) Link to this comment
hi Marc,
Thanks for the info. I need the custom web service for more things and since I like to have everything in one place I’ll leave it for now. The idea of using GetAllSubwebs is interesting, but I’m not quite sure about performance. Suppose I have 200 sites and 20 of those are retrieved after filtering. I´d then have to fire my query to each of those 20 sites and combine the results. I wonder if that´s truely faster then just querying everything and filtering afterwards. As I´ve read in a few blogs that SPSiteDataQuery is the fastest way to get data from sharepoint, that is when your CAML is ok of course.
Marc
October 10, 2010 at 8:11 am (UTC -4) Link to this comment
You might want to look at what other filter options you have. For instance, if you could filter on WebFullUrl or RootFolder. Since you’re working in code, you don’t really need the CAML properties.
M.
Jasper Siegmund
October 10, 2010 at 9:09 am (UTC -4) Link to this comment
I do, SPSiteDataQuery requires a CAML XML query for the ‘where’ parameter. I have the feeling you don’t know SPSiteDataQuery? :)
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx
Trygve
November 2, 2010 at 3:59 pm (UTC -4) Link to this comment
I have the same question as Jasper. I’m using a basic client-side call to Webs.asmx. My SOAP envelope contains a CAML query much like a basic Lists.asmx query (Lists works Webs doesn’t).
I’m assuming I just don’t have the proper CAML. Maybe FieldRef isn’t correct in this case?
\
\
\
\
\
\
SomeText \
\
\
\
\
\
Marc
November 2, 2010 at 9:21 pm (UTC -4) Link to this comment
Trygve:
I’m not sure of your question. Which Webs operation are you trying to use?
M.
Shiri
January 12, 2012 at 3:29 am (UTC -4) Link to this comment
Hi Marc,
Thanks for this post!
I’m using Dataview to display a list from a site in several sub sites. I want to filter them by the site title. I tried to use the ProjectProperty.Title but it’s showing the title of the original site and not the sub site, do you have any idea how to show the title of the current site?
Thank you,
Shiri
Marc
January 15, 2012 at 4:22 pm (UTC -4) Link to this comment
Shiri:
It’s a little difficult to know what to recommend without seeing your XSL. I do think what you want to do is possible.
M.
Shiri
January 22, 2012 at 4:43 am (UTC -4) Link to this comment
Hi Mark,
My XSL was as you wrote it in the blog – i added the to the SelectCommand and used it in the RowView template: .
Anyhow, I used another method – I used GetAllSubWebCollection from webs.asmx, filtered it by URL and used the title.
Of course your suggestion is easier, but I had to finish the task..
Thank you,
Shiri