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 November 3rd, 2005, 12:40 PM
Registered User
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to format data in xslt

I have converted a MS Project file into an xml and now using an xslt file to output the data as a webpage. There's a field in the xml file that contains the duration of the project in the following format "PT773H36M0S", this format contains teh durations in terms of hours, minutes and seconds. In my example, 773 hours and 36 minutes. I need to go through this data character by character and output how many hours and minutes there is. Can i do this through certain methods in xslt???

Old November 3rd, 2005, 02:38 PM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

XSLT 2.0 (from today a Candidate Recommendation!) supports durations as a native datatype, so you can do

<xsl:variable name="d" select="xdt:datTimeDuration(.)"/>
<xsl:value-of select="hours-from-duration($d)"/>
<xsl:value-of select="minutes-from-duration($d)"/>

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to format date using XSLT navi25584 XSLT 3 September 2nd, 2008 07:00 AM
Data Format Issue---need help please zone Excel VBA 0 August 13th, 2007 04:21 PM
Converting XML into a particular format using XSLT AjayLuthria XSLT 1 April 10th, 2007 09:47 AM
XSLT - Convert the date in different format haixia XSLT 1 August 25th, 2006 11:51 AM
Date format in XSLT rk2203 XSLT 2 November 29th, 2005 04:10 AM

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