title: XSLT functions and namespaces
body: <p>I'm kind of new to XSLT, and I've gotten basic transformation done. Next I want to try out date manipulations, since my data will have timestamps. However, I can't seem to get any date functions to work, and it greatly frustrates me. I'm testing using Firefox 3.5, xsltproc 1.1.24, xalan 1.10, and XMLSpy 2009, and they all say that the functions I'm trying to use don't exist.</p>
  
  <p>My xml looks like so:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="datetime.xsl"?&gt;
  
  &lt;watcher&gt;
    &lt;event id="1" date="2009-09-04T13:49:10-0500" type="ABCD"&gt;This is a test  &lt;/event&gt;
  &lt;/watcher&gt;
  &lt;/code&gt;
  </code></pre>
  
  <p>My xsl looks like so:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="2.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
  &lt;xsl:template match="event[@type='ABCD']"&gt;
  &lt;!--            Date: &lt;xsl:value-of select="day-from-dateTime(xs:dateTime(@date))"/&gt; --&gt;
  &lt;!--            Date: &lt;xsl:value-of select="day-from-dateTime(@date)"/&gt; --&gt;
                  Date: &lt;xsl:value-of select="fn:day-from-dateTime(@date)"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>If I make the stylesheet version 2, XMLSpy complains that it can't cast my date: <code>XSLT 2.0 Debugging Error: Error in XPath 2.0 expression (Cast failed, invalid lexical value - xs:dateTime '2009-09-04T13:49:10-0500')</code></p>
  
  <p>If I leave it as version 1, it complains about a different error: <code>XSLT 1.0 Debugging Error: Error in XPath expression (Unknown function - Name and number of arguments do not match any function signature in the static context - 'day-from-dateTime')</code></p>
  
  <p>Anytime I try to change the XSL to use a namespace, such as fn:day-from-dateTime, it refuses to work at all, with all of my parsers saying that <code>The function number 'http://www.w3.org/2005/02/xpath-functions:day-from-dateTime' is not available</code> and variants thereof. I know from other tests that I can use the substring() function perfectly, without needing any namespace prefix, and I believe it's in the same namespace as day-from-dateTime.</p>
  
  <p>I feel like it's something incredibly easy, since all of the tutorials show functions being used, but something seems to be eluding me. Could someone show me what I'm missing?</p>