Supporters of End User
Web

Unlocking the Mysteries of Data View Web Part XSL Tags - Part 1: Overview

Item is currently unrated. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.
Categories:MOSS; WSS; 2007; 2010; SharePoint Designer; Data View Web Part; Site Manager/Power User; Unlocking the Mysteries of the Data View Web Part

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!

<xsl-template>
Think of a template as a subroutine. It’s a unit of XSL to which you pass control.

<xsl:call-template>
This is how you call a template which you've defined with <xsl-template>.

<xsl:with-param>
You use this with <xsl:call-template> when you want to pass a value into a template, usually a value that varies.

<xsl:param>
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.

<xsl:variable>
A value you create for use within a template which is only defined within the scope of that template.

<xsl:for-each>
A way to iterate over a nodeset (group of rows).

<xsl:sort>
Used within an <xsl:for-each> to determine the sort order in which the nodeset (group of rows) are processed.

<xsl:if>
A single conditional test. If the test is true, then the contained code is executed.

<xsl:choose>
Like <xsl:if>, but with multiple possibilities, more like if-then-else.

<xsl:when>
Used within <xsl:choose> as a conditional test.  If the test is true, then the contained code is executed and the <xsl:choose> is exited.

<xsl:otherwise>
Used within <xsl:choose> as the "fall-back" condition. If none of the prior <xsl:when>s have been executed, the code contained here is executed.

<xsl:value-of>
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.

Comments

Ron

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Thanks Marc.

Looking Forward for other posts

Posted 19-Jan-2010 by Ron
Michael Greene

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Marc,

As we spoke offline, I've been very much looking forward to this series. I'm no dummy when it comes to web development technologies, but the DVWP has always sort of alluded me. I like where you're taking this, and look forward to reading the rest of the series.

Posted 19-Jan-2010 by Michael Greene
Adam Carr

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Nice article Mark, a good solid explaination of XSL and easy to follow.

Posted 19-Jan-2010 by Adam Carr
Matt B.

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Just caught this from @TeamEUSP. It's nice to see a clear explaination somewhere on the web. BTW, thanks for guiding me through the XSL date/time math...

Posted 19-Jan-2010 by Matt B.
Jeremy Howard

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Thank you Marc. I look forward to the rest of the series. It has been tough to know where to start in my XSL learning. Perhaps following you is the best way sine you know how to break things down into real English for us laymen.

Thanks again!

- jeremy

Posted 20-Jan-2010 by Jeremy Howard
Sam Allgood

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

crufty? What is crufty? ?8=()

Posted 20-Jan-2010 by Sam Allgood
Marc D Anderson

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

It's surprising to me, but 'crufty' doesn't actually seem to be a word. However, the Jargon File comes to the rescue: http://www.catb.org/jargon/html/C/crufty.html

;+)

M.

Posted 20-Jan-2010 by Marc D Anderson
spevilgenius

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

I think crufty is a newly coined technical term!

Great article! I love what you can do with XSL!

Posted 21-Jan-2010 by spevilgenius
Ayman El-Hattab

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

This is a must follow series, keep it up Marc

Posted 21-Jan-2010 by Ayman El-Hattab
Dan

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Great lesson, Marc! Thanks for taking the time to demystify XSL. I look forward to your future posts on this topic.

Posted 22-Jan-2010 by Dan
SharePoint Blogs in German

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

SharePoint Kaffeetasse 159... SharePoint 2010 SharePoint Designer 2010 Edit in Advanced Mode SharePoint 2010 Better Together with SQL...

Posted 05-Feb-2010 by SharePoint Blogs in German
Christian Stahl

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Excellent Marc! Thanks for all your work about this, this is a keeper.

Posted 09-Mar-2010 by Christian Stahl
4 Clicks or 1? Using jQuery to Start a SharePoint Workflow. | Intelligence Among Us

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

[...] Once that was done I need to do a few things.  I created a Web Part Page and opened SharePoint Designer.  I then added the Change Request list to one of the web part zones.  In order to get the customizations that wanted needed to create a DataView out of it so I simply right clicked on the list and converted it to a XSLT Dataview.   That’s all I really need to do here so I saved the page and opened it up in the browser.  What you can do with a dataview is almost limitless.  The best way to tackle customizations is to make all the changes you can using the SPD interface.  Once you have reached the limits of what you can do there you can start customizing the XSL.  Refer to the following series by Marc to learn everything you need to know about XSL and the DVWP.  http://www.endusersharepoint.com/2010/01/19/unlocking-the-mysteries-of-data-view-web-part-xsl-tags-p... [...]

Posted 19-Apr-2010 by 4 Clicks or 1? Using jQuery to Start a SharePoint Workflow. | Intelligence Among Us
SharePoint: Mailto Hyperlink in a DVWP | EndUserSharePoint.com

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

[...] can utilize XSLT functions to extract the email address.  Marc Anderson has a great series on mastering the Data view web part.  In this scenario we will be working with 2 string functions, substring-before and [...]

Posted 24-May-2010 by SharePoint: Mailto Hyperlink in a DVWP | EndUserSharePoint.com
SharePoint: Extending the DVWP – Part 9: Oops! Failed Setting Processor Stylesheet | EndUserSharePoint.com

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

[...] Yes, this is squarely advanced XSLT editing. Need help? See Marc Anderson’s excellent EUSP series Unlocking the Mysteries of Data View Web Part XSL Tags. [...]

Posted 10-Jun-2010 by SharePoint: Extending the DVWP – Part 9: Oops! Failed Setting Processor Stylesheet | EndUserSharePoint.com
Ajay

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Great Job Marc, it is excellent start for me on XSLT with DataViewWebPart.

Posted 13-Aug-2010 by Ajay
Marc Anderson

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

Ajay:

Buy the eBook and get all of the articles in one convenient PDF! :+)

M.

Posted 13-Aug-2010 by Marc Anderson
Rik Helsen

Unlocking the Mysteries of Data View Web Part XSL Tags – Part 1: Overview

We've just released a slideshare with an advanced/alternative approach on working with data view webparts, specifically the xslt editing part:

http://www.slideshare.net/orbitone/share-cafe-dataviewwebparts

Kind regards,
Rik

Posted 15-Sep-2010 by Rik Helsen
Overlooking T. Obvious

Navigation?

Is it me, or is the navigation to "Part 2" NOWHERE TO BE FOUND ON THIS PAGE?

Posted 02-Nov-2011 by Overlooking T. Obvious
Bob E

I little sparse

This is a good start but please try and flesh it out a bit more. 

Posted 09-Nov-2011 by Bob E
Jay

Dynamic Filtering

Marc, I purchased your book last year and it really help me solve a several issues. I'm currently working on building a new view utilizing the dvwp and the way I'm wanting the dvwp to work seems like would be simple to do, but I haven't been able to find a example that fits. I'm hoping you can point me in the right direction or an example. If I was writing this in .NET, JAVA, or any other programming language my stored procedure would look like this : select field1, field2, field3, field4 from table1 where field4 in(select field4 from table2 where table2.user = $currentUser) The stored procedure would pass back a result set to load in whatever time of data source viewer object chosen and displayed. With that being said it seems that it would be easy to have the dvwp filter a column from any valid data source that returns a list of values to compare. The reason for this approach is have the data already filter for permission the user is allowed to view and they can only filter that data return and not be able to remove the base filter and I already a permissions for the data being maintain via another system so if I can pull this data to control permission it solves a lot of issues. I do have the permission table in a list view already using BCS. If I'm over complicating please let me know. Any ideas, examples, or point in the right direction would be appreciated. Thanks Jay

Posted 01-Feb-2012 by Jay
Julia

XSLT Book Rec

XSLT rocks, it's one of my favorite things about Sharepoint.  Sick, I know.  This is one of my favorite IT books, XSLT Quickly, highly recommended for Sharepoint developers:
 
 
 
 
 
 

Posted 27-Mar-2012 by Julia
Sri

Predecessor Task List View

Hi Marc,
 
Is it possible to use the Data View Web Part to create Predecessor Task List View? I mean I have task list, some task may have Predecessor task so I asked to create Predecessor view.
 
Please let me know.
 
Thank you
 
Sri

Posted 08-Nov-2012 by Sri
Peter Brase

What a Gold Mine of Information!

I have been searching for this info for a long time.  Many many thanks for this excellent work!

Posted 10-May-2013 by Peter Brase
somesh

Somesh

I have created a dataview using sharepoint list as datasource, applied filters through querystring.
When i search the data it pulls only matching records from first ten.
But i want to pull the first ten matching records. could you please suggest

Posted 31-Aug-2013 by somesh

Notify me of comments to this article

E-mail:
   

Add Comment

Title:

 
Comment:
Email:

   


Name:

 
Url: