Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 16th, 2010, 12:06 PM
Authorized User
 
Join Date: May 2007
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old February 16th, 2010, 12:14 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05:39 PM
deployment chapter hard to follow robert BOOK: ASP.NET Website Programming Problem-Design-Solution 3 June 20th, 2003 01:22 PM



All times are GMT -4. The time now is 09:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.