Given date + Days = Next Date?

14 views
Skip to first unread message

Thomas Lehmann

unread,
Sep 23, 2011, 10:14:44 AM9/23/11
to xs...@googlegroups.com
Hi,

Assume the start of a project is defined by attribute "start": 13.9.2011 (just an example)
Now I calculate a value in days for a project (basing on estimations).
How do I calculate the end date?

Folgendes funktioniert nicht:
<xsl:value-of select="@start + $days"/>

Grüße
Thomas

Christian Wahl

unread,
Sep 26, 2011, 8:17:56 AM9/26/11
to xs...@googlegroups.com
I think you need support for XPath 2.0 like http://www.exslt.org/ to calculate dates.

You can see a list of functions here:
http://www.w3.org/TR/xquery-operators/#comp.duration.datetime
or here:
http://www.w3schools.com/xpath/xpath_functions.asp#datetime

– otherwise you are on your one with string manipulation.

How are you doing your transformations?

Thomas Lehmann

unread,
Sep 27, 2011, 8:52:26 AM9/27/11
to xs...@googlegroups.com
Usually I'm using the automatic transforming by defining it in the XML.
I know .... the transformation depends then on the browser.

The advantage is that a change in the XML does not require
manual work also a final HTML is just a one line command.

I solved the problem - for now - by generating a dates.xml
with dates and offset as attributes and inside of the tag the
result of the calculation $date + $days. A simple python
script does the job. The final query is simple:
<xsl:value-of select="document('dates.xml')/*/date[@start=$start-date and @days=$calculated-days]"/>

I know - most will shake their heads - including me.

Reply all
Reply to author
Forward
0 new messages