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 February 16th, 2010, 12:06 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date handling (follow up)

If I have the following XML input:

<schedule>
<time>
<start>2010-11-07T22:00:00-06:00</start>
<ending>2010-11-07T23:00:00-06:00</ending>
<value>2.0</value>
</time>
<time>
<start>2010-11-07T23:00:00-06:00</start>
<ending>2010-11-08T00:00:00-06:00</ending>
<value>8.0</value>
</time>
<time>
<start>2010-11-07T02:00:00-06:00</start>
<ending>2010-11-07T03:00:00-06:00</ending>
<value>7.0</value>
</time>
</schedule>

The problem I am having is that the above XML defines a set of times that are not in sequential order and I need to select the last <time> for that day. In this case, I would want to select the 2nd <time> node.

Any help is greatly appreciated.

Thanks.
 
Old February 16th, 2010, 12:14 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can use max(time/ending/xs:dateTime(.)), or you can sort time element using

<xsl:sort select="xs:dateTime(ending)"/>

and choose the last.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Difficult to Follow - Anyone Agree? projectedNexus BOOK: ASP.NET Website Programming Problem-Design-Solution 25 July 31st, 2006 04:39 PM
deployment chapter hard to follow robert BOOK: ASP.NET Website Programming Problem-Design-Solution 3 June 20th, 2003 12:22 PM





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