473,545 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using XSL to calculate time (t = hh:mi + mi)

Hi,
I have an XML source which gives me the start time (in the format
hh:mi) of a program and the duration of the program (in minutes).

With XSLT only, I would like to generate the time the next program
starts.
Ex: If the current program starts at 10:30 and lasts for 60 minutes, I
wish to display that the next program starts at 11:30.
The server seems to be running XSL 1.0.

I am quite new to XSLT, and have tried Googling this with no luck so
far.

Can anyone please help me with this? (Preferably with code example..
;-)

Regards, Per Magnus

Dec 1 '06 #1
5 3578
ke*********@hot mail.com wrote:
With XSLT only, I would like to generate the time the next program
starts.
Ex: If the current program starts at 10:30 and lasts for 60 minutes, I
wish to display that the next program starts at 11:30.
The server seems to be running XSL 1.0.
XSLT/XPath 1.0 have basic string parsing functions which allow you to
split up that value into two numbers, then you can compute the time in
minutes, add the other minutes value and then you need to convert back
to a time value.
XPath string functions are here:
<http://www.w3.org/TR/xpath#section-String-Functions>
XPath number operators (div, mod) and functions are here:
<http://www.w3.org/TR/xpath#numbers>
<http://www.w3.org/TR/xpath#section-Number-Functions>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 1 '06 #2

Martin Honnen schrieb:
ke*********@hot mail.com wrote:
XSLT/XPath 1.0 have basic string parsing functions which allow you to

that sounds not like a job xslt, because the string functions (i.e.
substring-after ect...) are TOO basic.

Other question: which XSLT-Parser ?

Dec 1 '06 #3
I'm not sure what XSLT parser we have here. Any easy way to figure this
out?
Its hard to find the administrator of the server here, and my guess is
that if I find him, he does not have this information at the top of his
head.

Is the XSLT parser significant for this type of task?

I have implemented a preliminary solution to this, though, using string
parsing anf number(), substing(), floor(), div and mod functions in the
XSL statement.

For special interested, the time for next program became:

<xsl:choose>
<xsl:when test =
"floor((number( substring(nr/st,4,2))+number (nr/ln)) div
60)+number(subs tring(nr/st,1,2)) &gt; 23" >
<xsl:value-of
select="floor(( number(substrin g(nr/st,4,2))+number (nr/ln)) div
60)+number(subs tring(nr/st,1,2)) mod 24"/>
</xsl:when>
<xsl:otherwis e >
<xsl:value-of
select="floor(( number(substrin g(nr/st,4,2))+number (nr/ln)) div
60)+number(subs tring(nr/st,1,2))"/>
</xsl:otherwise>
</xsl:choose>:<xs l:choose><xsl:w hen test =
"((number(subst ring(nr/st,4,2))+number (nr/ln)) mod 60) &lt;
10">0<xsl:val ue-of select="(number (substring(nr/st,4,2))+number (nr/ln))
mod 60"/>
</xsl:when>
<xsl:otherwis e >
<xsl:value-of select="(number (substring(nr/st,4,2))+number (nr/ln))
mod 60"/>
</xsl:otherwise>
</xsl:choose>

Thanks for help!

-Per Magnus

fedro wrote:
Martin Honnen schrieb:
ke*********@hot mail.com wrote:
XSLT/XPath 1.0 have basic string parsing functions which allow you to


that sounds not like a job xslt, because the string functions (i.e.
substring-after ect...) are TOO basic.

Other question: which XSLT-Parser ?
Dec 1 '06 #4
ke*********@hot mail.com schrieb:

<xsl:choose>
<xsl:when test =
"floor((number( substring(nr/st,4,2))+number (nr/ln)) div
60)+number(subs tring(nr/st,1,2)) &gt; 23" >
<xsl:value-of
select="floor(( number(substrin g(nr/st,4,2))+number (nr/ln)) div
60)+number(subs tring(nr/st,1,2)) mod 24"/>
</xsl:when>
<xsl:otherwis e >
<xsl:value-of
select="floor(( number(substrin g(nr/st,4,2))+number (nr/ln)) div
60)+number(subs tring(nr/st,1,2))"/>
</xsl:otherwise>
</xsl:choose>:<xs l:choose><xsl:w hen test =
"((number(subst ring(nr/st,4,2))+number (nr/ln)) mod 60) &lt;
10">0<xsl:val ue-of select="(number (substring(nr/st,4,2))+number (nr/ln))
mod 60"/>
</xsl:when>
<xsl:otherwis e >
<xsl:value-of select="(number (substring(nr/st,4,2))+number (nr/ln))
mod 60"/>
</xsl:otherwise>
</xsl:choose>

Thanks for help!

-Per Magnus
Look at this. That's my point, that is not a job for XSLT, maybe
XSLT2.0 or so, but that is cruel to debug and performance and
everything.

This job has to be done by an extension, i.e. a very shot Java Funtion.

Dec 1 '06 #5

<ke*********@ho tmail.comwrote in message
news:11******** *************@n 67g2000cwd.goog legroups.com...
Hi,
I have an XML source which gives me the start time (in the format
hh:mi) of a program and the duration of the program (in minutes).

With XSLT only, I would like to generate the time the next program
starts.
Ex: If the current program starts at 10:30 and lasts for 60 minutes, I
wish to display that the next program starts at 11:30.
The server seems to be running XSL 1.0.

See my Calendar XSLT app:

http://www.topxml.com/code/?p=3&id=v...odelib&sw=lang

It uses a library datetime_lib.xs l (written entirely in XSLT by Martin
Rowlinson) from XSelerator and can be accessed from the trial download.

As for what can be done with XSLT and how efficient this is -- many people
have really wrong believes. Read my blog to find examples:

http://dnovatchev.spaces.live.com/Blog/

or see my snippets (written many years ago) on topxml.com:

http://www.topxml.com/members/profile.asp?id=i1005

Cheers,
Dimitre Novatchev
Dec 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

62
3318
by: christopher diggins | last post by:
Since nobody responded to my earlier post , I thought I would try to explain what I am doing a bit differently. When multiply inheriting pure virtual (abstract) base classes, a class obviously bloats quickly for each new vtable needed. Execution slows down considerably as well. You can work around this by using interfaces referemnces which...
6
15633
by: Richard A. Lowe | last post by:
I'm using P/Invoke to call SendInput (using code culled from these newsgroups!) to send mouse events to a window. But I'm unsure how to send double-clicks. A VB6 article I saw on SendInput suggested simply queueing two click events, but this is not working for me, regardless of the delay I put between clicks. So give this as a click (where...
5
4814
by: Totto | last post by:
Hi, Is it possible to convert date to dd mon yyyy hh:mi(24h) Thanks Totto
26
5196
by: canteyn | last post by:
I am currently working on a lab for my computer science class, and we are to write program (using a function) to calculate the monthly payment. We also are reading the principal loan, interest rate, and number of payments from a file, and then passing this values to the function which returns the "monthly payment". Then we write the monthly...
0
3225
by: jobs | last post by:
re: Oracle Exceeded maximum idle time I have asp.net web gridview that is populated by a function that calls an Oracle procedure that returns a dataset. At most, it might take 2 or 4 seconds to come back on average. However, somtimes I get this error. ORA-02396: exceeded maximum idle time, please connect again Where should i adjust my...
1
1699
by: RubyRed | last post by:
Using SQL Server 2000. Basically, I am trying to calculate each minute of an employee scheduled time during their work shift. In the table below shows only the times that the shift begin (start_minute), ended (sched_endtime) and times (dtl_start_min, dtl_length, dtl_end_min) the employee went on Break, lunch, etc... What the table does not show...
3
2364
by: PeeS290 | last post by:
Hi all, Where can I find guidelines about programming SQL based applications in VC++ ? Since MS SQL Server 2008 is strongly promoted, I cannot understand why there is no help for developers. There is so many technologies using SQL, but no clear guidelines which one to use. Last one I tried is ODBC, but I don't know if I should stick to...
6
11427
by: gozdeata | last post by:
hey there, i m trying to get only time information of a date type variable. i got a column in type of char, it keeps time info in hh:mm format - 5 characters when i tried to convert it to date with to_date(, 'hh24:mi') it gives me a date starts with the ifrst day of current mount, year etc. 01/10/2008 14:04 for example. i need a solution to...
0
19536
amitpatel66
by: amitpatel66 | last post by:
Hi All, Find below some useful information about Time Zone Conversion in oracle. Hope this would be helpful for many of them since all the real time projects that we work in follow different time zones (EST,PST etc) and you might well need to convert them to something specific as per your requirements: insert into dates values(6,...
0
7486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7932
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6001
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.