I had EXSLT kernel date functions that worked well in some XSL templates that I have been using for many years. I would like to start using the new: seconds . This function is not one of the โcoreโ functions, and therefore implementations may require compliance with EXSLT without it.
I am using Cocoon 2.1.11 with Xalan 2.7.1, which seems to have decided not to implement date:seconds .
Fortunately, the good people at EXSLT provide downloads to help you plug in individual features, but I can't figure out how to actually get the plugin.
I can use the basic functions using this template, for example:
<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" > <xsl:template match="/"> <xsl:value-of select="date:date-time()" /> </xsl:template> </xsl:stylesheet>
When trying to use the date.seconds function date.seconds I tried the following:
- Just add
<xsl:import href="date.seconds.xsl" /> to my template and with date:seconds() . This causes the error message "The extension function could not find the org.apache.xalan.lib.ExsltDatetime.seconds method" - Removing
xmlns:date as shown above. This causes me the error "Prefix must resolve namespace: date" - Placing the contents of
date.seconds.xsl inside the template I'm trying to write, and then calling date:seconds() without an argument (by default it used the current time). I get this error message: "Calling the instance method to the second method requires an instance of the object as the first argument." Now it looks promising. - Adding an argument to
date:seconds . I get an error: "The extension function could not find the java.lang.String.seconds ([ExpressionContext,]) methodโ
Any suggestions for using this non-core EXSLT function?
Here is my current template that still tells me that it is trying to call java.lang.String.seconds() :
<?xml version="1.0" ?> <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"> <xsl:import href="date.seconds.xsl" /> <func:script language="exslt:javascript" implements-prefix="date" src="date.js"/> <func:script language="exslt:msxsl" implements-prefix="date" src="date.msxsl.xsl"/> <xsl:template match="/"> <xsl:value-of select="date:seconds('2014-02-27')" /> </xsl:template> </xsl:stylesheet>
source share