[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
tom tom wrote:
You are on the right track. Make sure you spell the yearMonthDuration correctly (there are no days in a yearMonthDuration constructor) and do not use the xdt namespace anymore (http://www.w3.org/2004/10/xpath-datatypes), because it has been superseded by the namespace of XMLSchema (http://www.w3.org/2001/XMLSchema). Commonly the 'xs' prefix is used, like with XML Schema datatypes. The rest is simple: just use normal arithmetic and you are done:
<xsl:sequence select="current-date() + xs:yearMonthDuration('P2Y1M')" as="xs:date" />
will add two years and one month to today.
Re: [xsl] Adding duration to date
Subject: Re: [xsl] Adding duration to date From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Tue, 24 Jul 2007 19:03:14 +0200 |
tom tom wrote:
I wish to add a duration to a date, something along the lines of:
<xsl:value-of select="current-date() + xdt:yearMonthDuration('P6D')"/>.
I am using saxon 8.x, what is the correct way to do this, what should my namespace declarations be to make this work and does the way I do this depend on which version of Saxon / another processor I am using?
You are on the right track. Make sure you spell the yearMonthDuration correctly (there are no days in a yearMonthDuration constructor) and do not use the xdt namespace anymore (http://www.w3.org/2004/10/xpath-datatypes), because it has been superseded by the namespace of XMLSchema (http://www.w3.org/2001/XMLSchema). Commonly the 'xs' prefix is used, like with XML Schema datatypes. The rest is simple: just use normal arithmetic and you are done:
<xsl:sequence select="current-date() + xs:yearMonthDuration('P2Y1M')" as="xs:date" />
will add two years and one month to today.
Cheers, -- Abel Braaksma
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Adding duration to date, Andrew Welch | Thread | Re: [xsl] Adding duration to date, Abel Braaksma |
Re: [xsl] Adding duration to date, Andrew Welch | Date | Re: [xsl] Adding duration to date, Abel Braaksma |
Month |
Keywords