SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am customizing the ItemStyle.xsl in SPD2010 for a CQWP crawling a whole site collection. I need to use the current web as a variable.

I tried multiple options:

  • Option #1 - use server variables in a similar way to what you do with a DVWP but I do not see where I would set up the block


  • Option #2 - use the ddwrt namespace functions I have successfully added the namespace to the ItemStyle.xsl and it does work great to retreive the page URL



However, when trying the same trick to retrieve Httphost, HttpVDir and other parameters, it simply didn't work (returned blank). Note: my SP website is using https...

  • Option #3 - Use the parameter(s) defined in the ContentQueryMain.xsl It seems that I should be able to access the paramters defined there from the ItemStyle.xsl but I probably don't do it properly... Any help?

share|improve this question

If you're doing this kind of thing often, you could create a new class that inherits from CQWP, and passes data you need through to the XSL, using the ModifyXslArgumentList method.


share|improve this answer
I unfortunately don t have the ability/ or knowledge to go beyond SharePoint Designer... – Greg in Chicago Aug 25 '11 at 1:14

In ContentQueryMain.xsl are declared the following parameters:

  • SiteUrl - URL of the current site collection
  • WebUrl - URL of current web site

In ItemStyle.xsl current web site url could be specified as demonstrated below:

<a href="{$WebUrl}/_layouts/userdisp.aspx?id={$AuthorId}"><xsl:value-of select="@Author" /></a>

Note: In order to encode URL string UrlEncode function could be used

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.