title: Using non-core EXSLT date functions with Xalan Java
body: <p>I have had EXSLT's core date functions working well in some XSL templates I've been using for years. I'd like to start using a new one: <code>seconds</code>. This function is not one of the "core" functions and therefore implementations can claim compliance with EXSLT without actually implementing it.</p>
  
  <p>I'm using Cocoon 2.1.11 with Xalan 2.7.1 which, it appears, has chosen not to implement <code>date:seconds</code>.</p>
  
  <p>Fortunately, the kind folks at EXSLT provide downloads to help you plug-in individual functions but I can't seem to figure out how to actually achieve the plug-in.</p>
  
  <p>I can use the core functions easily using this template for instance:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:date="http://exslt.org/dates-and-times" &gt;
    &lt;xsl:template match="/"&gt;
      &lt;xsl:value-of select="date:date-time()" /&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>When attempting to use the <code>date.seconds</code> function, I have tried the following:</p>
  
  <ol>
  <li>Simply adding <code>&lt;xsl:import href="date.seconds.xsl" /&gt;</code> to my template, and using <code>date:seconds()</code>. This gets me the error message "For extension function, could not find method org.apache.xalan.lib.ExsltDatetime.seconds"</li>
  <li>Removing the <code>xmlns:date</code> as shown above. This gets me the error "Prefix must resolve to a namespace: date"</li>
  <li>Placing the contents of <code>date.seconds.xsl</code> within the template I'm trying to write, then calling <code>date:seconds()</code> with no argument (it's defined to use the current time by default). I get this error message: "Instance method call to method seconds requires an Object instance as first argument". This is looking promising, now.</li>
  <li>Adding an argument to <code>date:seconds</code>. I get the error message: "For extension function, could not find method java.lang.String.seconds([ExpressionContext,] )"</li>
  </ol>
  
  <p>Any suggestions for how to use this non-core EXSLT function?</p>
  
  <p>Here is my current template, still telling me that it's trying to call <code>java.lang.String.seconds()</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:func="http://exslt.org/functions"
      xmlns:date="http://exslt.org/dates and times"&gt;
    &lt;xsl:import href="date.seconds.xsl" /&gt;
    &lt;func:script language="exslt:javascript" implements-prefix="date" src="date.js"/&gt;
    &lt;func:script language="exslt:msxsl" implements-prefix="date" src="date.msxsl.xsl"/&gt;
  
    &lt;xsl:template match="/"&gt;
      &lt;xsl:value-of select="date:seconds('2014-02-27')" /&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>