The SPXSLT Codeplex Project – New XSL Templates

Cross-posted from EndUserSharePoint.com

About a month ago, at the suggestion of @iwkid, I created a new Codeplex project called SPXSLT.  My goal was to start providing a library of useful XSL templates for people to use in Data View Web Parts (DVWPs) or Content Query Web Parts (CQWPs) in SharePoint.  It’s a bit different from most Codeplex projects in that (at least so far), I’m not building releases. I’m simply using the Documentation section of the project to contain the XSL templates and their descriptions.

With all the work I do with DVWPs, I often find myself copying and pasting utility templates that I’ve built over time from old projects into new ones.  I’ve had my own messy store of these templates across my hard disks and VMs, and it seemed to make good sense to start sharing them for wider use.  There’s zero point in any of us writing these things over and over (unless we really just want to work too hard).

I would suggest that you create a file (I usually call mine Utilities.XSL) and store it centrally for use in DVWPs and CQWPs across your sites.  In WSS, I create a Document Library called XSL in the root site of the Site Collection and put the file there, along with any other commonly used XSL files.  In MOSS, I store these XSL files in ‘/Style Library/XSL Style Sheets’.

You can then add any of the templates from SPXSLT that you want to use in the Utilities.xsl file and include these utility templates in your DVWPs.  Take a look at my article Unlocking the Mysteries of Data View Web Part XSL Tags – Part 20: xsl:import to see how this process works.

The SPXSLT project has been languishing a bit, so today I added a set of new templates to get things moving again.  The new templates are GetUserIDs, MailtoUser, and MailtoUsers.

The full inventory of templates which I currently have available is listed below.

Name Short Description Requires Type Categories
FirstNWords Displays the first N words from a string of text. (Use StripHTML first if your content includes markup.) NA Template String
GetPercentileValue Given a nodeset and a percentile (expressed as a number from 0-100), returns the percentile value of a column. NA Template Statistical
GetUserID This template returns the user’s ID from a Person or Group value. NA Template User
GetUserIDs This template returns the user IDs from a Person or Group column which allows multi-select. GetUserID Template User
GetUserName This template returns the user’s name from a Person or Group value. NA Template User
GetUserEmail This template returns the user’s Email from a Person or Group value. NA Template User
MailtoUser This template returns a mailto: link for the user’s Email from a Person or Group value. NA Template User
MailtoUsers This template returns mailto: links for the user Emails from a Person or Group column which allows multi-select. MailtoUser Template User
StripHTML Strips the HTML tags out of a section of content. NA Template HTML

As with my other Codeplex project, SPServices*, I’m always looking for ideas and submissions to help expand the capabilities for SPXSLT.  Let me hear from you!

* A jQuery library which abstracts SharePoint’s Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.

2 Comments

    • Christophe:

      Obviously, performance is always a consideration. I haven’t seen issues in any of my projects, but there are many ways you could mitigate issues if they do arise (e.g., splitting the templates into logical groupings in separate files).

      I find that people tend to fear performance issues and therefore don’t try this stuff. My suggestion is to implement and deal with performance issues when you have them. Servers these days have so much power that we have to do pretty silly things to use their resources up.

      M.

      Reply

Have a thought or opinion?