| From | Sent On | Attachments |
|---|---|---|
| Andrew Welch | Apr 18, 2008 4:53 am | |
| David Carlisle | Apr 18, 2008 5:06 am | |
| John Snelson | Apr 18, 2008 5:12 am | |
| Mukul Gandhi | Apr 18, 2008 5:48 am | |
| Dimitre Novatchev | Apr 18, 2008 5:54 am | |
| Mukul Gandhi | Apr 18, 2008 5:56 am | |
| Robert Koberg | Apr 18, 2008 6:03 am | |
| Andrew Welch | Apr 18, 2008 6:05 am | |
| David Carlisle | Apr 18, 2008 6:19 am | |
| Colin Paul Adams | Apr 18, 2008 6:35 am | |
| Michael Ludwig | Apr 18, 2008 7:11 am | |
| Liam Quin | Apr 18, 2008 7:24 am | |
| Liam Quin | Apr 18, 2008 7:33 am | |
| Robert Koberg | Apr 18, 2008 7:34 am | |
| Colin Paul Adams | Apr 18, 2008 7:38 am | |
| Abel Braaksma | Apr 18, 2008 7:38 am | |
| Colin Paul Adams | Apr 18, 2008 7:45 am | |
| Michael Ludwig | Apr 18, 2008 7:46 am | |
| Abel Braaksma | Apr 18, 2008 7:47 am | |
| Andrew Welch | Apr 18, 2008 7:48 am | |
| Abel Braaksma | Apr 18, 2008 7:50 am | |
| Abel Braaksma | Apr 18, 2008 7:54 am | |
| Abel Braaksma | Apr 18, 2008 7:56 am | |
| Dimitre Novatchev | Apr 18, 2008 7:57 am | |
| Abel Braaksma | Apr 18, 2008 7:58 am | |
| Colin Paul Adams | Apr 18, 2008 8:03 am | |
| Dimitre Novatchev | Apr 18, 2008 8:04 am | |
| Andrew Welch | Apr 18, 2008 8:07 am | |
| Dimitre Novatchev | Apr 18, 2008 8:16 am | |
| Andrew Welch | Apr 18, 2008 8:19 am | |
| Andrew Welch | Apr 18, 2008 8:38 am | |
| Michael Ludwig | Apr 18, 2008 8:45 am | |
| Dimitre Novatchev | Apr 18, 2008 9:01 am | |
| Abel Braaksma | Apr 18, 2008 9:29 am | |
| Robert Koberg | Apr 18, 2008 2:20 pm | |
| Liam Quin | Apr 18, 2008 6:42 pm | |
| Liam Quin | Apr 18, 2008 6:44 pm | |
| Dimitre Novatchev | Apr 18, 2008 7:30 pm | |
| Michael Kay | Apr 19, 2008 12:27 am | |
| Michael Kay | Apr 19, 2008 12:37 am | |
| Mukul Gandhi | Apr 19, 2008 12:38 am | |
| Michael Kay | Apr 19, 2008 1:51 am | |
| Michael Ludwig | Apr 19, 2008 2:20 am | |
| Andrew Welch | Apr 19, 2008 2:39 am | |
| Mukul Gandhi | Apr 19, 2008 8:24 am | |
| Dimitre Novatchev | Apr 19, 2008 9:11 am |
| Subject: | Re: [xsl] current-dateTime() | |
|---|---|---|
| From: | Abel Braaksma (abel...@xs4all.nl) | |
| Date: | Apr 18, 2008 7:38:46 am | |
| List: | com.mulberrytech.lists.xsl-list | |
Andrew Welch wrote:
I wrongly thought that the "implementation dependent" part meant the processor could return different values for multiple calls to current-dateTime()... instead of merely the freedom to choose the instant at which it takes the fixed value.
It should be straightforward to write an extension function instead...
it may be tempting to write an extension function, but that binds you to a certain implementation and it really is unnecessary. It'd be nicer to get the current time/date at any moment of processing by means of standard XSLT / XPath functionality. This discussion thread makes it seem that such a thing is not possible, but, with a little help from the Internet, it actually is possible.
This is a short version of a related post of my, about one and a half years back.
Ingredients: 1) XSLT 2.0 processor that supports the document() function with the the HTTP URI scheme 2) An internet (HTTP) source that returns the current time and date 3) Access to that source (configure your firewall if necessary) 4) a little effort to make XSLT 2.0 act non-pure-functional
I assume for the moment that 1-3 are easy to grasp and arrange. Nr 4 may need a little help:
<xsl:function name="my:randomString" as="xs:string"> <xsl:variable name="node"> <xsl:comment /> </xsl:variable> <xsl:sequence select="generate-id($node)" /> </xsl:function>
<xsl:function name="my:current-DateTime" as="xs:dateTime"> <xsl:variable name="dateTimeUrl" select="concat('http://yourtimesite/getTimeDate.pl?', my:randomString())" /> <xsl:sequence select="document($dateTimeUrl)/currentDateTimeNode" /> </xsl:function>
There are obvious drawbacks and caveats to this solution, one being that the Net overhead is significant, the other being that the dependencies on external systems may be a larger problem to deal with then an extension function. But whatever it is, the point I was trying to make is that you can get the current date or time at the current execution point (regardless the ordered or unordered execution of the stylesheet) without using anything non-XSLT-like (I won't say non-declarative like, simply because the side effects I employ are not part of declarative programming).
A time server can return either an XML document or, easier, a simple string. Then you'd use the unparsed-text() function.
Cheers, -- Abel Braaksma
--~------------------------------------------------------------------ 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-...@lists.mulberrytech.com> --~--





