Hi Anton,
Thanks for your reply -- you'll have seen my later message about what ended
up working (I called the function with incorrect syntax), but you raise some
issues here that I worked through as well. So in the spirit of
knowledge-sharing,
here are the answers to your queries:
At 11:15 AM 7/31/2004, you wrote:
Hi Chris,
you did import the exslt date stylesheet, didn't you?
(I don't see it in your fragment):
<xsl:import href="date.xsl" />
If you didn't, your stylesheet will know nothing about the named extension
templates (in other words, you're calling templates that don't exist)
No, I didn't import the exslt stylesheet. It's already supported by the
processor
I'm using (Xalan-J), so declaring the namespace is sufficient. Take a look at
the same web page you cite below for more details.
But I suppose you did import it... Then take a look at your template calls:
<xsl:call-template name="date:hour-in-day"/>
You are calling the template with no parameters! How can the template
know what date/time you want to extract the hours of?
The default call with no parameters returns the current system time, which
is what I wanted here. You can call it as you did below (and as the example
on the web page is set up), but that would require a separate call to the
date-time function (to populate the variable $date-str below) which isn't
necessary because the function returns what I want already.
You will need something like:
<xsl:call-template name="date:hour-in-day">
<xsl:with-param name="date-time" select="$date-str"/>
</xsl:call-template>
If you want the current system time, you will need to call the
appropriate function "date:date-time()".
(see http://www.exslt.org/date/functions/date-time/index.html)
HTH,
Anton Triest
Hope that helps! Thanks again for your reply.
----- Original Message -----
From: "Chris Loschen" <closchen(_at_)stanfordalumni(_dot_)org>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, July 30, 2004 10:24 PM
Subject: [xsl] EXSLT extension function
> Hi everybody!
>
> I'm trying to pull in the system time (I'll want the date as well, but one
> thing at a time...)
> to my XSLT stylesheet. It looked like the EXSLT functions had just what I
> need, and
> they're supposedly supported by my XSLT processor (Xalan-J 2.6). But I'm
> getting this
> error:
>
> javax.xml.transform.TransformerException: ElemTemplateElement error:
> date:hour-in-day
>
> I might have the namespace wrong or perhaps I'm not calling the extension
> function
> correctly? I've done a Google search without finding anything. Anybody
have any
> ideas? Thanks!
>
> Here is a fragment of the stylesheet (I know it's not well-formed -- I'm
> just copying the relevant section):
>
> <?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"
> extension-element-prefixes="date">
>
> <xsl:output method="xml" version="1.0" omit-xml-declaration="yes"
> indent="yes" />
>
> <xsl:template match="BillHeader">
> <xsl:variable name="time">
> <xsl:variable name="hours">
> <xsl:call-template name="date:hour-in-day"/>
> </xsl:variable>
> <xsl:variable name="minutes">
> <xsl:call-template name="date:minute-in-hour"/>
> </xsl:variable>
> <xsl:value-of select="concat($hours,$minutes)"/>
> </xsl:variable>
>
> etc.
>
> Yours,
>
> Chris Loschen
> closchen(_at_)stanfordalumni(_dot_)org
> 781-718-3017 (cell)
>
>
>
> --+------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
> --+--
>
>
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
Yours,
Chris Loschen
closchen(_at_)stanfordalumni(_dot_)org
781-718-3017 (cell)