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 <!-- ********************************************************************
11 $Id: pi.xsl,v 1.1 2007/03/10 05:14:55 scott Exp $
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 <!-- include extra test for Xalan quirk -->
114 <xsl:when test=
"function-available('exsl:node-set') or
115 contains(system-property('xsl:vendor'),'Apache Software Foundation')">
116 <!-- We must preserve context node in order to get valid language -->
117 <xsl:variable name=
"context" select=
"."/>
118 <xsl:for-each select=
"exsl:node-set($tokenized-format-string)/node()">
119 <xsl:variable name=
"token">
120 <xsl:value-of select=
"."/>
122 <!-- Restore context node -->
123 <xsl:for-each select=
"$context">
125 <xsl:when test=
"$token = 'a'">
126 <xsl:call-template name=
"gentext.template">
127 <xsl:with-param name=
"context" select=
"'datetime-abbrev'"/>
128 <xsl:with-param name=
"name" select=
"date:day-abbreviation($date)"/>
131 <xsl:when test=
"$token = 'A'">
132 <xsl:call-template name=
"gentext.template">
133 <xsl:with-param name=
"context" select=
"'datetime-full'"/>
134 <xsl:with-param name=
"name" select=
"date:day-name($date)"/>
137 <xsl:when test=
"$token = 'b'">
138 <xsl:call-template name=
"gentext.template">
139 <xsl:with-param name=
"context" select=
"'datetime-abbrev'"/>
140 <xsl:with-param name=
"name" select=
"date:month-abbreviation($date)"/>
143 <xsl:when test=
"$token = 'c'">
144 <xsl:value-of select=
"date:date($date)"/>
145 <xsl:text> </xsl:text>
146 <xsl:value-of select=
"date:time($date)"/>
148 <xsl:when test=
"$token = 'B'">
149 <xsl:call-template name=
"gentext.template">
150 <xsl:with-param name=
"context" select=
"'datetime-full'"/>
151 <xsl:with-param name=
"name" select=
"date:month-name($date)"/>
154 <xsl:when test=
"$token = 'd'">
155 <xsl:if test=
"$padding = 1 and
156 string-length(date:day-in-month($date)) = 1">0</xsl:if>
157 <xsl:value-of select=
"date:day-in-month($date)"/>
159 <xsl:when test=
"$token = 'H'">
160 <xsl:if test=
"$padding = 1 and string-length(date:hour-in-day($date)) = 1">0</xsl:if>
161 <xsl:value-of select=
"date:hour-in-day($date)"/>
163 <xsl:when test=
"$token = 'j'">
164 <xsl:value-of select=
"date:day-in-year($date)"/>
166 <xsl:when test=
"$token = 'm'">
167 <xsl:if test=
"$padding = 1 and string-length(date:month-in-year($date)) = 1">0</xsl:if>
168 <xsl:value-of select=
"date:month-in-year($date)"/>
170 <xsl:when test=
"$token = 'M'">
171 <xsl:if test=
"string-length(date:minute-in-hour($date)) = 1">0</xsl:if>
172 <xsl:value-of select=
"date:minute-in-hour($date)"/>
174 <xsl:when test=
"$token = 'S'">
175 <xsl:if test=
"string-length(date:second-in-minute($date)) = 1">0</xsl:if>
176 <xsl:value-of select=
"date:second-in-minute($date)"/>
178 <xsl:when test=
"$token = 'U'">
179 <xsl:value-of select=
"date:week-in-year($date)"/>
181 <xsl:when test=
"$token = 'w'">
182 <xsl:value-of select=
"date:day-in-week($date)"/>
184 <xsl:when test=
"$token = 'x'">
185 <xsl:value-of select=
"date:date($date)"/>
187 <xsl:when test=
"$token = 'X'">
188 <xsl:value-of select=
"date:time($date)"/>
190 <xsl:when test=
"$token = 'Y'">
191 <xsl:value-of select=
"date:year($date)"/>
194 <xsl:value-of select=
"$token"/>
202 Timestamp processing requires an XSLT processor with support
203 for the EXSLT node-set() function.