Re: [xsl] XSLT 2.0/XPath 2.0 Date arithmetic

Subject: Re: [xsl] XSLT 2.0/XPath 2.0 Date arithmetic
From: cknell@xxxxxxxxxx
Date: Thu, 18 May 2006 12:24:23 -0400
OK, I've installed 8.7.1 and I've solved the issue. Here is what I've got.

First the namespace issues:

"ck" is bound to a URL I own (xmlns:ck="http://www.surreylane.net";).
"xs" is bound as you would expect (xmlns:xs="http://www.w3.org/2001/XMLSchema";)

Both are in my opening stylesheet tag to give them scope over the whole stylesheet.

I munged the original parameter with substring() and concat() into the format "YYYY-MM-DD" as is required by xs:date (e.g., "2006-05-18") so that it is correct when I pass it to the function.

The function:

<xsl:function name="ck:subtract-a-day" as="xs:string">
  <xsl:param name="input-date" as="xs:string" />
  <xsl:sequence select="xs:string(xs:date($input-date) - xs:dayTimeDuration('P1D'))" />
</xsl:function>

I don't know what you call the string 'P1D', but in the original example given by Mike Kay, the string read 'PT1D' and Saxon complained about it. I put on my thinking cap (i.e., I made an educated guess as I couldn't figure out how to Google for what to call the thing and then my internet connection went down four about a half-hour.) and came up with 'P1D', which worked.

Thanks to all who contributed. I think I'm going to like XSLT 2.0.

-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     cknell@xxxxxxxxxx
Sent:     Thu, 18 May 2006 11:13:39 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  RE: Re: [xsl] XSLT 2.0/XPath 2.0 Date arithmetic

My copy reports itself to be 8.7J. I'll look for a later version, thanks.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     David Carlisle <davidc@xxxxxxxxx>
Sent:     Thu, 18 May 2006 16:06:33 +0100
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: [xsl] XSLT 2.0/XPath 2.0 Date arithmetic


> What am I missing? Thanks for your help.

in the public drafts dayTimeDuration is in Xquery's own xdt namespace
(the URI for which depends on exactly which draft you look at)
a bug entry in bugzilla confirms that this is finally going to move to
the schema namespace and I think saxon implements that from 8.7.1
onwards. Do you have an older implementation?

David

Current Thread