[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT 2.0/XPath 2.0 Date arithmetic

Subject: Re: XSLT 2.0/XPath 2.0 Date arithmetic
From: cknell@xxxxxxxxxx
Date: Thu, 18 May 2006 12:24:23 -0400
xslt 2.0 date
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:  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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.