2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 xmlns:date="http://exslt.org/dates-and-times"
5 xmlns:exsl="http://exslt.org/common"
6 exclude-result-prefixes="doc date exsl"
7 extension-element-prefixes="date exsl"
10 <!-- ********************************************************************
12 ********************************************************************
14 This file is part of the XSL DocBook Stylesheet distribution.
15 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
16 and other information.
18 This file contains general templates for processing processing
19 instructions common to both the HTML and FO versions of the
21 ******************************************************************** -->
23 <!-- Process PIs also on title pages -->
24 <xsl:template match="processing-instruction()" mode="titlepage.mode">
25 <xsl:apply-templates select="."/>
28 <xsl:template match="processing-instruction('dbtimestamp')">
29 <xsl:variable name="format">
30 <xsl:variable name="pi-format">
31 <xsl:call-template name="pi-attribute">
32 <xsl:with-param name="pis" select="."/>
33 <xsl:with-param name="attribute">format</xsl:with-param>
37 <xsl:when test="$pi-format != ''">
38 <xsl:value-of select="$pi-format"/>
41 <xsl:call-template name="gentext.template">
42 <xsl:with-param name="context" select="'datetime'"/>
43 <xsl:with-param name="name" select="'format'"/>
49 <xsl:variable name="padding">
50 <xsl:variable name="pi-padding">
51 <xsl:call-template name="pi-attribute">
52 <xsl:with-param name="pis" select="."/>
53 <xsl:with-param name="attribute">padding</xsl:with-param>
57 <xsl:when test="$pi-padding != ''">
58 <xsl:value-of select="$pi-padding"/>
60 <xsl:otherwise>1</xsl:otherwise>
64 <xsl:variable name="date">
66 <xsl:when test="function-available('date:date-time')">
67 <xsl:value-of select="date:date-time()"/>
69 <xsl:when test="function-available('date:dateTime')">
71 <xsl:value-of select="date:dateTime()"/>
77 <xsl:when test="function-available('date:date-time') or
78 function-available('date:dateTime')">
79 <xsl:call-template name="datetime.format">
80 <xsl:with-param name="date" select="$date"/>
81 <xsl:with-param name="format" select="$format"/>
82 <xsl:with-param name="padding" select="$padding"/>
87 Timestamp processing requires XSLT processor with EXSLT date support.
94 <xsl:template name="datetime.format">
95 <xsl:param name="date"/>
96 <xsl:param name="format"/>
97 <xsl:param name="padding" select="1"/>
99 <xsl:if test="$format != ''">
100 <!-- replace any whitespace in the format string with a non-breaking space -->
101 <xsl:variable name="format-nbsp"
102 select="translate($format,
103 ' 	
',
104 '    ')"/>
105 <xsl:variable name="tokenized-format-string">
106 <xsl:call-template name="str.tokenize.keep.delimiters">
107 <xsl:with-param name="string" select="$format-nbsp"/>
108 <xsl:with-param name="delimiters" select="' ,./-()[]'"/>
113 <xsl:when test="function-available('exsl:node-set')">
114 <!-- We must preserve context node in order to get valid language -->
115 <xsl:variable name="context" select="."/>
116 <xsl:for-each select="exsl:node-set($tokenized-format-string)/node()">
117 <xsl:variable name="token">
118 <xsl:value-of select="."/>
120 <!-- Restore context node -->
121 <xsl:for-each select="$context">
123 <xsl:when test="$token = 'a'">
124 <xsl:call-template name="gentext.template">
125 <xsl:with-param name="context" select="'datetime-abbrev'"/>
126 <xsl:with-param name="name" select="date:day-abbreviation($date)"/>
129 <xsl:when test="$token = 'A'">
130 <xsl:call-template name="gentext.template">
131 <xsl:with-param name="context" select="'datetime-full'"/>
132 <xsl:with-param name="name" select="date:day-name($date)"/>
135 <xsl:when test="$token = 'b'">
136 <xsl:call-template name="gentext.template">
137 <xsl:with-param name="context" select="'datetime-abbrev'"/>
138 <xsl:with-param name="name" select="date:month-abbreviation($date)"/>
141 <xsl:when test="$token = 'c'">
142 <xsl:value-of select="date:date($date)"/>
143 <xsl:text> </xsl:text>
144 <xsl:value-of select="date:time($date)"/>
146 <xsl:when test="$token = 'B'">
147 <xsl:call-template name="gentext.template">
148 <xsl:with-param name="context" select="'datetime-full'"/>
149 <xsl:with-param name="name" select="date:month-name($date)"/>
152 <xsl:when test="$token = 'd'">
153 <xsl:if test="$padding = 1 and
154 string-length(date:day-in-month($date)) = 1">0</xsl:if>
155 <xsl:value-of select="date:day-in-month($date)"/>
157 <xsl:when test="$token = 'H'">
158 <xsl:if test="$padding = 1 and string-length(date:hour-in-day($date)) = 1">0</xsl:if>
159 <xsl:value-of select="date:hour-in-day($date)"/>
161 <xsl:when test="$token = 'j'">
162 <xsl:value-of select="date:day-in-year($date)"/>
164 <xsl:when test="$token = 'm'">
165 <xsl:if test="$padding = 1 and string-length(date:month-in-year($date)) = 1">0</xsl:if>
166 <xsl:value-of select="date:month-in-year($date)"/>
168 <xsl:when test="$token = 'M'">
169 <xsl:if test="string-length(date:minute-in-hour($date)) = 1">0</xsl:if>
170 <xsl:value-of select="date:minute-in-hour($date)"/>
172 <xsl:when test="$token = 'S'">
173 <xsl:if test="string-length(date:second-in-minute($date)) = 1">0</xsl:if>
174 <xsl:value-of select="date:second-in-minute($date)"/>
176 <xsl:when test="$token = 'U'">
177 <xsl:value-of select="date:week-in-year($date)"/>
179 <xsl:when test="$token = 'w'">
180 <xsl:value-of select="date:day-in-week($date)"/>
182 <xsl:when test="$token = 'x'">
183 <xsl:value-of select="date:date($date)"/>
185 <xsl:when test="$token = 'X'">
186 <xsl:value-of select="date:time($date)"/>
188 <xsl:when test="$token = 'Y'">
189 <xsl:value-of select="date:year($date)"/>
192 <xsl:value-of select="$token"/>
200 Timestamp processing requires an XSLT processor with support
201 for the EXSLT node-set() function.