Sharepoint XSLT Template (Boilerplate)

SharePoint XSLT Template / Boilerplate

XSLT is pretty cool once you learn how it works. Honestly though, I never had any desire to really play with it though until SharePoint Designer removed the design view functionality. Once that disappeared, I decided all those years (a decade plus) of only mingling with XSLT was going to need to get very serious if I wanted to keep up my relationship with SharePoint 2013.

Thankfully, I have enough knowledge around development so decided I would just take on XSLT head on! Well, I quickly realized I would need to start small if I wanted to mess with any XSLT view that SharePoint spits out. So with that, I give you the XSLT boilerplate template for SharePoint.

Download Now!

Use the attached XSLT template as a boilerplate style to your SharePoint web part,
...

How to Implement SharePoint XSLT Boilerplate / Template

Well, there are a ton of different ways to utilize an XSLT template in SharePoint, so I’m going to assume that you also have a basic understanding of programming to not only implement, but also modify the template to your liking. After all, you wouldn’t have stumbled across this article if you didn’t have some understanding…right?

The basics to the below should be enough to get you started. First, you paste the entire template between the
<XSL></XSL> sections in your web part. Within the template you will see the two sections below. This is for your basic, plain-jane HTML table. The first section is the container for template, and the highlighted rows are where the second section is called, which is the repeating section (rows) for the table.

This template will generate a repeating table of your data based on what columns you call. This example calls the ‘title’ column and the ‘description’ columns from your SharePoint list.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<!--Start First Template-->

<xsl:template match="/"xmlns:x="http://www.w3.org/2001/XMLSchema">

<xsl:variable name="Rows"select="/dsQueryResponse/Rows/Row"/>

<table>

<tr>

<td>Title</td>

<td>Description</td>

</tr>

<xsl:for-eachselect="$Rows">

<xsl:call-template name="dvt_1.rowview"/>

</xsl:for-each>

</table>

</xsl:template>

<!--EndFirst Template-->

<!--Start Standard Rows First Template-->

<xsl:template name="dvt_1.rowview">

<tr>

<td><xsl:value-of select="@Title"/></td>

<td><xsl:value-of select="@Description"/></td>

</tr>

</xsl:template>

<!--EndStandard Rows First Template-->

So that does it! Hopefully now you will be on your way to styling up some sexy web parts in SharePoint. As always, feel free to drop a comment below if you have any questions or need assistance.