Re: [xslt] confusing error message "function format-date bound to undefined prefix date"
- From: Michael Ludwig <mlu as-guides com>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] confusing error message "function format-date bound to undefined prefix date"
- Date: Tue, 24 Mar 2009 10:50:05 +0100
Viktor Stujber schrieb:
Greetings. We had some trouble when modifying our presentation layer
to use (e)xslt date formatting. The problematic code looked like this:
<xsl:value-of select="date:format-date(str:replace($date, ' ', 'T'),
'HH:mm:ss | dd. MMMM, yy')"/>
This line worked on its author's test setup, which used an older
libxslt version. But when deployed on our webserver, it started
throwing errors:
xmlXPathCompOpEval: function format-date bound to undefined prefix date
xmlXPathCompiledEval: 1 objects left on the stack.
First, the error message strongly suggests you haven't bound the prefix
"date" to a namespace. As a consequence, the XPath expression cannot be
compiled.
Second, as this extension function isn't supported natively be LibXSLT,
which can be checked by doing `xsltproc --dumpextensions`, you have to
include the EXSLT function supplied by Jeni Tennison in your transform.
http://www.exslt.org/date/functions/format-date/index.html
This has a dependency on "str.padding.function.xsl", which you can
remove when using LibXSLT, as it is implemented natively in this
processor. See the example below.
Michael Ludwig
<xsl:stylesheet version="1.0"
xmlns:str="http://exslt.org/strings"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="date.format-date.function.xsl"/>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="date" select="'2009-03-23 10:21:00'"/>
<xsl:variable name="fmt" select="'HH:mm:ss | dd. MMMM, yy'"/>
<xsl:value-of select="str:replace( $date, ' ', 'T')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="
date:format-date( str:replace( $date, ' ', 'T'), $fmt)"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]