Skip to Content
XSLT Cookbook, 2nd Edition
book

XSLT Cookbook, 2nd Edition

by Sal Mangano
December 2005
Intermediate to advanced content levelIntermediate to advanced
774 pages
19h 30m
English
O'Reilly Media, Inc.
Content preview from XSLT Cookbook, 2nd Edition

Chapter 4. Dates and Times

Does anyone really know what time it is? Does anyone really care?

Chicago

Introduction

Native XSLT 1.0 does not know what time it is and does not seem to care. However, dates and times are a necessary aspect of everyday life. The need to manipulate them arises frequently in computing, especially in web development. Therefore, it was surprising and unfortunate that standard XSLT 1.0 did not have any built-in date and time support.

The situation in XSLT 2.0 has improved substantially. XPath 2.0 has numerous functions for manipulating dates, times, and durations. In fact, the only thing 2.0 leaves us wanting for, with respect to date and time, is functions with shorter names! I am told names like subtract-dates-yielding-yearMonthDuration() were provided partly to appease the XQuery database weenies. The alternation between dashes and camelcase follows from the differing conventions adopted by XPath and XML Schema committees.

The examples in this section can help compensate for XSLT 1.0’s lack of support for dates and times. Unfortunately, one of the most crucial date and time capabilities cannot be implemented in XSLT 1.0—that is, getting the current date and time. For that, you need to call out to another language whose library supports interacting with the hardware’s real-time clock. Both Java and JavaScript have this capability. If your application just needs to format dates and times that already exist in a document, then the routines here should cover ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XSLT Cookbook

XSLT Cookbook

Sal Mangano
XSLT, 2nd Edition

XSLT, 2nd Edition

Doug Tidwell
XSLT for Dummies

XSLT for Dummies

Richard Wagner
XSLT

XSLT

Doug Tidwell

Publisher Resources

ISBN: 0596009747Supplemental ContentErrata Page