Thoughts and Notes Ideas that stay with me long enough to get written down

12Nov/070

Using EXSLT date-time functions in Saxon 6.5.5

I needed to put a time-stamp in a file I was generating with XSLT and Saxon. Saxon supports parts of EXSLT, and one of the parts supported is @date:date-time@. It's kind of challenging to figure out exactly how to make it work, though, at least it was for me. In hopes that I'll save someone else some work, here's how to add a time-stamp using Saxon 6.5.5.

<?xml version="1.0" encoding="UTF-8"?>
<xsl :stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:saxon="http://icl.com/saxon"
xmlns:exsl="http://exslt.org/common"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:func="http://exslt.org/functions"
extension-element-prefixes="saxon exsl date func">
<xsl:template match="/">
Date-time: <xsl :value-of select="date:date-time()"/>
Date-year: <xsl :value-of select="date:year()"/>
Date-month-in-year: <xsl :value-of select="date:month-in-year()"/>
</xsl:template>
</xsl>

I hope that helps someone.