Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2009, 01:10 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default evaluating time and building a sequence of values

<units>
<unit>
<start>2009-04-16T00:00:00-05:00</start>
<end>2009-04-16T02:00:00-05:00</end>
<value>35</value>
</unit>
<unit>
<start>2009-04-16T02:00:00-05:00</start>
<end>2009-04-16T05:00:00-05:00</end>
<value>40</value>
</unit>
<unit>
<start>2009-04-16T22:00:00-05:00</start>
<end>2009-04-17T00:00:00-05:00</end>
<value>44</value>
</unit>
</units>

Desired result would be a sequence of 24 values captured in a variable so that it can be iterated thru later:

35 35 40 40 40 null null null null null null null null null null null null null null null null null 44 44

Currently, I am using the following code, but thought there might be a more efficient way to solve this problem:

<xsl:variable name="values" select="for $i in (1 to 24) return if (units/unit[$i gt (hours-from-dateTime(start))][$i lt (if (hours-from-dateTime(end) eq 0) then 25 else hours-from-dateTime(end) + 1)]) then format-number(units/unit[$i gt (hours-from-dateTime(start) )][$i lt (if (hours-from-dateTime(end) eq 0) then 25 else hours-from-dateTime(end) + 1)]/value, '######.##') else 'null'"/>

Any suggestions are greatly appreciated.

Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Evaluating IF something is in a list fizzerchris SQL Server 2005 2 October 17th, 2007 05:37 PM
Evaluating body content of a custom tag Tag Librarian Pro JSP 0 May 13th, 2005 02:40 PM
Some of Time Values aijazamg C# 3 January 23rd, 2005 06:24 PM
Adding two time values j_karthik72 VBScript 1 April 5th, 2004 06:43 AM
Evaluating Textbox in Realtime without postback mahulda ASP.NET 1.0 and 1.1 Basics 5 March 10th, 2004 03:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.