Great XSLT website for functions/templates

May 25, 2010 at 8:10 AM

I have needed to do Date manipulation in XSLT for my SharePoint projects. On searching around, I found this site: http://www.exslt.org/

They have a number of "modules", including a whole bunch on Dates and Times, and have several different implementations of each function, including XSL Templates that work with XSLT v1.0 (why is SharePoint still in the XSL dark ages!?)

I did find that I needed to tweak them a little to work within a DVWP, though I might be doing something wrong... here's what I needed to do.

1. The "how to" page on the website explains how to add the namespace (e.g. all the date templates are prefixed with "date:"), but I couldn't get that to work, so I effectively removed the namespace by removing the ":"

2. I needed to modify the <xsl:stylesheet version="1.0" extension-element-prefixes="date"> at the top of the templates to be the same <xsl:stylesheet> as used in the main DVWP

3. Occasionally there are XML fragments in the templates (e.g. for Month lengths), which are referenced like this:
<xsl:variable name="month-days" select="document('')/*/date:month-lengths/date:month"/>
I changed these to have an XSL Variable surrounding the fragments and changed the accessing code to be as follows:
<xsl:variable name="month-days" select="msxsl:node-set($datemonth)/datemonth-lengths/datemonth"/>

4. I also found on one occasion that a newline in the template (inside the "test" of an <xsl:if statement>) gave an error, but simply removing the line breaks solved this problem.

I have been very happy with the results of using these templates, so hope others find them helpful. If you would like me to post the slightly-modified versions, I'd be happy to.

Alex

Feb 12, 2014 at 12:45 PM
Alex,

I've recently encountered a similar issue with getting the date:difference to function properly. It has been ages since your post but I'd be interested in seeing the modified versions if, you still have them. I've wrapped the fragment mentioned in your post as you have but I am still having trouble getting the values out. I probably fat-fingered something somewhere is my guess but I'd like a known working version to compare and learn what it is I did wrong. Thanks
Feb 12, 2014 at 7:53 PM
dml wrote:
Alex,

I've recently encountered a similar issue with getting the date:difference to function properly. It has been ages since your post but I'd be interested in seeing the modified versions if, you still have them. I've wrapped the fragment mentioned in your post as you have but I am still having trouble getting the values out. I probably fat-fingered something somewhere is my guess but I'd like a known working version to compare and learn what it is I did wrong. Thanks
Situation corrected, was a namespace issue. These templates are working like a charm now