The stylesheets have a feature to generate date and time strings. These can be used to insert the processing date for display or for meta data. These features make use of the EXSLT date-time()
function. That function is supported by the Saxon, Xalan, and xsltproc processors, but not MSXSL.
There is no DocBook element that represents the current date, so the stylesheets use a processing instruction to insert a timestamp. Here is an example:
<para>This document was generated
<?dbtimestamp format="Y-m-d H:M:S"?>.</para>
When processed, this input will result in the following output in either HTML or print:
This document was generated 2003-07-23 12:13:00.
The dbtimestamp
processing instruction name triggers the date functions, and the format
string is used to select and format the components of date and time. The component letters are as follows:
Date-time format letter | Example | Description |
---|---|---|
a | Thu | Day abbreviation |
A | Thursday | Day name |
b | Jul | Month abbreviation |
c | 2003-07-10-07:00 12:20:33-07:00 | Complete ISO date and time, including offset from UTC. |
B | July | Month name |
d | 10 | Day in month |
H | 11 | Hour in day |
j | 191 | Day in year |
m | 07 | Month in year |
M | 20 | Minute in hour |
S | 14 | Second in minute |
U | 28 | Week in year |
w | 5 | Day in week (Sunday = 1) |
x | 2003-07-10-07:00 | ISO date |
X | 12:20:33-07:00 | ISO time |
Y | 2003 | Year. |
Any other characters in the format string are passed through, allowing you to add punctuation as needed.
You can also use the date functions more directly in a customization layer. See the section “Adding a date timestamp” for an example.
DocBook XSL: The Complete Guide - 3rd Edition | PDF version available | Copyright © 2002-2005 Sagehill Enterprises |