Data View Web Parts (DVWPs) are, to me, the most powerful feature in SharePoint. You've probably heard them called the Swiss Army Knife of SharePoint and there's really very little that you can't display with them if you understand how they work. But understanding the inner working of DVWPs requires knowledge of some pretty crufty concepts: CAML and XSL. In this series, I hope to demystify the XSL side of things a bit by explaining the most common XSL tags you're likely to see in DVWPs and what you can do with them.
For this first post in the series, let me list out what I see as the most common XSL tags used in DVWPs generated only by using SharePoint Designer's dialogs. You're liable to see most, if not all, of these tags if you switch to Split or Code view and start rummaging around in the code. The definitions are mine, and I intend them to be simplistic, so you purists out there may need to check your vocabulary at the door!
Think of a template as a subroutine. It’s a unit of XSL to which you pass control.
This is how you call a template which you've defined with
You use this with
<xsl:call-template> when you want to pass a value into a template, usually a value that varies.
A value you've passed into a template with
<xsl:with-param>. You need to have an
<xsl:param> at the top of the template for each value you expect to be passed into it.
A value you create for use within a template which is only defined within the scope of that template.
A way to iterate over a nodeset (group of rows).
Used within an
<xsl:for-each> to determine the sort order in which the nodeset (group of rows) are processed.
A single conditional test. If the test is true, then the contained code is executed.
<xsl:if>, but with multiple possibilities, more like if-then-else.
<xsl:choose> as a conditional test. If the test is true, then the contained code is executed and the
<xsl:choose> is exited.
<xsl:choose> as the "fall-back" condition. If none of the prior
<xsl:when>s have been executed, the code contained here is executed.
Outputs the value to which it evaluates, whether it be the value of a column, a variable, etc.
There are more XSL tags available, but this set is what you are most likely to run into in a Data View Web Part (DVWP). As we continue on with this series, I'll give some examples of how you may see each of these tags used, some other interesting things you might want to do, and the results.