[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Summing Time Durations Help

Subject: RE: Summing Time Durations Help
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 5 Oct 2005 09:35:59 +0100
xsl time duration
>     Kent> I have some duration elements like <alltimes>
>     Kent> <tduration>PT1H23M</tduration> <tduration>PT5M</tduration>
>     Kent> <tduration>PT44M12S</tduration>
>     Kent> <tduration>PT57M23S</tduration> ...  </alltimes>
> 
>     Kent> What is the most efficient way to sum the durations?  Is
>     Kent> there an xpath = expression for this?
> 
> Yes. If you are using XPath 2.0.
> You should use the sum() function.
> But first you need some duration values - at present, all you have are
> string literals - untyped text nodes.

Colin, you're right, on the assumption that there's no schema and that the
transformation isn't schema-aware. If there's a schema that describes these
elements as being of type xdt:dayTimeDuration, and if you use a schema-aware
processor, then you can just sum them directly: sum(tduration).

Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.