I first discovered the use of XSL formatting when we were trying to make links in a links app open in a new window. It’s funny how SharePoint lets you open other links in a new tab, but for some reason the app that’s geared specifically for the creation of links won’t open those links in a new tab.
Using XSL allows you to step away from always displaying your content in a spreadsheet-like list, and can help display your content in a more user-friendly way.
While working with XSL files is an advanced skill, and definitely not for the faint of heart, the toughest part of the process is making sure that you have the correct field names. The field name that is shown on the List View is not always the name of the field that SharePoint uses to display the fields. Therefore you need to find the actual SharePoint field name. To find that field name, go to the List Settings for the list you’re looking to display and then right-click on the name of the column you’re looking for. Copy the link and paste it in a notepad window. Your web address will look something like this.
The field name in this case is Company, and so you would use @Company in the XSL file to reference it.
For hyperlinks, the field actually has 2 components: the URL and the description. So for a field such as Web Page (below), you would need @WebPage as well as @WebPage.desc
When creating XSL files, it’s best to work from an existing file. When you need to create new fields, use syntax similar to that shown here.
Then, to use those new fields in your page, use syntax such as this:
The disable-output-escaping=”yes” portion of the code is invaluable. It will make sure that descriptions or text fields appear with HTML code intact. This means that links will work, as will ampersands (&) and other such characters. If you do not include that code, you would end up with HTML code showing on the page.
Handling spaces in field names with XSL
If your field name has spaces or other characters, you’ll end up with a field name that looks like this: Field=Buildings%5Fx002d%5FResLife
It looks a little messy but it’s just SharePoint’s way of handing these characters in field names. In order to work with this kind of a field name, replace the %5F with an underscore. A space will then look like _x0020_ and a hyphen will look like _x002d_ as shown in the image below.