summaryrefslogtreecommitdiffstats
blob: 5535415c0a81327f39a0045dcef194ee5afc6923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?xml version='1.0'?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  xmlns:date="http://exslt.org/dates-and-times"
  xmlns:exsl="http://exslt.org/common"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  exclude-result-prefixes="doc date exsl"
  extension-element-prefixes="date exsl"
  version='1.0'>

<!-- ********************************************************************
     $Id: pi.xsl 8349 2009-03-17 06:53:03Z bobstayton $
     ********************************************************************

     This file is part of the XSL DocBook Stylesheet distribution.
     See ../README or http://docbook.sf.net/release/xsl/current/ for
     copyright and other information.

     ******************************************************************** -->

<doc:reference xmlns=""><info><title>Common Processing Instruction Reference</title>
    <releaseinfo role="meta">
      $Id: pi.xsl 8349 2009-03-17 06:53:03Z bobstayton $
    </releaseinfo>
  </info>
  <partintro id="partintro">
    <title>Introduction</title>
    <para>This is generated reference documentation for all
      user-specifiable processing instructions (PIs) in the
      “common” part of the DocBook XSL stylesheets.
      <note>
        <para>You add these PIs at particular points in a document to
          cause specific “exceptions” to formatting/output behavior. To
          make global changes in formatting/output behavior across an
          entire document, it’s better to do it by setting an
          appropriate stylesheet parameter (if there is one).</para>
      </note>
    </para>
  </partintro>
</doc:reference>

<!-- ==================================================================== -->
<doc:pi name="dbchoice_choice" xmlns="">
  <refpurpose>Generates a localized choice separator</refpurpose>
  <refdescription id="select.choice.separator-desc">
    <para>Use the <tag class="xmlpi">dbchoice choice</tag> PI to
      generate an appropriate localized “choice” separator (for
      example, <literal>and</literal> or <literal>or</literal>)
      before the final item in an inline <tag>simplelist</tag></para>
    <warning>
      <para>This PI is a less-than-ideal hack; support for it may
        disappear in the future (particularly if and when a more
        appropriate means for marking up "choice" lists becomes
        available in DocBook).</para>
    </warning>
  </refdescription>
  <refsynopsisdiv>
    <synopsis><tag class="xmlpi">dbchoice choice="and"|"or"|<replaceable>string</replaceable>"</tag></synopsis>
  </refsynopsisdiv>
  <refparameter>
    <variablelist>
      <varlistentry><term>choice="and"</term>
        <listitem>
          <para>generates a localized <literal>and</literal> separator</para>
        </listitem>
      </varlistentry>
      <varlistentry><term>choice="or"</term>
        <listitem>
          <para>generates a localized <literal>or</literal> separator</para>
        </listitem>
      </varlistentry>
      <varlistentry><term>choice="<replaceable>string</replaceable>"</term>
        <listitem>
          <para>generates a literal <replaceable>string</replaceable> separator</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
</doc:pi>
<xsl:template name="pi.dbchoice_choice">
  <xsl:param name="node" select="."/>
  <xsl:call-template name="pi-attribute">
    <xsl:with-param name="pis" select="$node/processing-instruction('dbchoice')"/>
    <xsl:with-param name="attribute">choice</xsl:with-param>
  </xsl:call-template>
</xsl:template>

<doc:pi name="dbtimestamp" xmlns="">
  <refpurpose>Inserts a date timestamp</refpurpose>
  <refdescription>
    <para>Use the <tag class="xmlpi">dbtimestamp</tag> PI at any point in a
      source document to cause a date timestamp (a formatted
      string representing the current date and time) to be
      inserted in output of the document.</para>
  </refdescription>
  <refsynopsisdiv>
    <synopsis><tag class="xmlpi">dbtimestamp format="<replaceable>formatstring</replaceable>" [padding="0"|"1"]</tag></synopsis>
  </refsynopsisdiv>
  <refparameter>
    <variablelist>
      <varlistentry><term>format="<replaceable>formatstring</replaceable>"</term>
        <listitem>
          <para>Specifies format in which the date and time are
            output</para>
        <note>
          <para>For details of the content of the format string,
            see <link role="tcg" xlink:href="Datetime.html"
              >Date and time</link>.</para>
        </note>
        </listitem>
      </varlistentry>
      <varlistentry><term>padding="0"|"1"</term>
        <listitem>
          <para>Specifies padding behavior; if non-zero, padding is is added</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
</doc:pi>
<xsl:template name="pi.dbtimestamp">
  <xsl:variable name="format">
    <xsl:variable name="pi-format">
      <xsl:call-template name="pi-attribute">
        <xsl:with-param name="pis" select="."/>
        <xsl:with-param name="attribute">format</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$pi-format != ''">
        <xsl:value-of select="$pi-format"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="gentext.template">
          <xsl:with-param name="context" select="'datetime'"/>
          <xsl:with-param name="name" select="'format'"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable> 
  <xsl:variable name="padding">
    <xsl:variable name="pi-padding">
      <xsl:call-template name="pi-attribute">
        <xsl:with-param name="pis" select="."/>
        <xsl:with-param name="attribute">padding</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$pi-padding != ''">
        <xsl:value-of select="$pi-padding"/>
      </xsl:when>
      <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="date">
    <xsl:choose>
      <xsl:when test="function-available('date:date-time')">
        <xsl:value-of select="date:date-time()"/>
      </xsl:when>
      <xsl:when test="function-available('date:dateTime')">
        <!-- Xalan quirk -->
        <xsl:value-of select="date:dateTime()"/>
      </xsl:when>
    </xsl:choose>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="function-available('date:date-time') or
      function-available('date:dateTime')">
      <xsl:call-template name="datetime.format">
        <xsl:with-param name="date" select="$date"/>
        <xsl:with-param name="format" select="$format"/>
        <xsl:with-param name="padding" select="$padding"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:message>
        Timestamp processing requires XSLT processor with EXSLT date support.
      </xsl:message>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<doc:pi name="dbtex_delims" xmlns="">
  <refpurpose>Generates delimiters around embedded TeX equations
    in output</refpurpose>
  <refdescription>
    <para>Use the <tag class="xmlpi">dbtex delims</tag> PI as a
      child of a <tag>textobject</tag> containing embedded TeX
      markup, to cause that markup to be surrounded by
      <literal>$</literal> delimiter characters in output.</para>
  </refdescription>
  <refsynopsisdiv>
    <synopsis><tag class="xmlpi">dbtex delims="no"|"yes"</tag></synopsis>
  </refsynopsisdiv>
  <refparameter>
    <variablelist>
      <varlistentry><term>dbtex delims="no"|"yes"</term>
        <listitem>
          <para>Specifies whether delimiters are output</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refparameter>
  <refsee role="params">
    <para><parameter>tex.math.delims</parameter></para>
  </refsee>
  <refsee role="tcg">
    <para><link role="tcg"
        xlink:href="TexMath.html"
        >DBTeXMath</link></para>
  </refsee>
</doc:pi>
<xsl:template name="pi.dbtex_delims">
  <xsl:param name="node" select="."/>
  <xsl:call-template name="pi-attribute">
    <xsl:with-param name="pis" select="$node/processing-instruction('dbtex')"/>
    <xsl:with-param name="attribute" select="'delims'"/>
  </xsl:call-template>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="processing-instruction()" mode="titlepage.mode">
  <!-- * Als process PIs on title pages -->
  <xsl:apply-templates select="."/>
</xsl:template>

<xsl:template match="processing-instruction('dbtimestamp')">
  <xsl:call-template name="pi.dbtimestamp"/>
</xsl:template>

<xsl:template name="datetime.format">
  <xsl:param name="date"/>
  <xsl:param name="format"/>
  <xsl:param name="padding" select="1"/>
  <xsl:if test="$format != ''">
    <!-- replace any whitespace in the format string with a non-breaking space -->
    <xsl:variable name="format-nbsp"
      select="translate($format,
      '&#x20;&#x9;&#xd;&#xa;',
      '&#xa0;&#xa0;&#xa0;&#xa0;')"/>
    <xsl:variable name="tokenized-format-string">
      <xsl:call-template name="str.tokenize.keep.delimiters">
        <xsl:with-param name="string" select="$format-nbsp"/>
        <xsl:with-param name="delimiters" select="'&#xa0;,./-()[]:'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$exsl.node.set.available != 0">
        <!-- We must preserve context node in order to get valid language -->
        <xsl:variable name="context" select="."/>
        <xsl:for-each select="exsl:node-set($tokenized-format-string)/node()">
          <xsl:variable name="token">
            <xsl:value-of select="."/>
          </xsl:variable>
          <!-- Restore context node -->
          <xsl:for-each select="$context">
            <xsl:choose>
              <xsl:when test="$token = 'a'">
                <xsl:call-template name="gentext.template">
                  <xsl:with-param name="context" select="'datetime-abbrev'"/>
                  <xsl:with-param name="name" select="date:day-abbreviation($date)"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:when test="$token = 'A'">
                <xsl:call-template name="gentext.template">
                  <xsl:with-param name="context" select="'datetime-full'"/>
                  <xsl:with-param name="name" select="date:day-name($date)"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:when test="$token = 'b'">
                <xsl:call-template name="gentext.template">
                  <xsl:with-param name="context" select="'datetime-abbrev'"/>
                  <xsl:with-param name="name" select="date:month-abbreviation($date)"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:when test="$token = 'c'">
                <xsl:value-of select="date:date($date)"/>
                <xsl:text> </xsl:text>
                <xsl:value-of select="date:time($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'B'">
                <xsl:call-template name="gentext.template">
                  <xsl:with-param name="context" select="'datetime-full'"/>
                  <xsl:with-param name="name" select="date:month-name($date)"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:when test="$token = 'd'">
                <xsl:if test="$padding = 1 and
                  string-length(date:day-in-month($date)) = 1">0</xsl:if>
                <xsl:value-of select="date:day-in-month($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'H'">
                <xsl:if test="$padding = 1 and string-length(date:hour-in-day($date)) = 1">0</xsl:if>
                <xsl:value-of select="date:hour-in-day($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'j'">
                <xsl:value-of select="date:day-in-year($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'm'">
                <xsl:if test="$padding = 1 and string-length(date:month-in-year($date)) = 1">0</xsl:if>
                <xsl:value-of select="date:month-in-year($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'M'">
                <xsl:if test="string-length(date:minute-in-hour($date)) = 1">0</xsl:if>
                <xsl:value-of select="date:minute-in-hour($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'S'">
                <xsl:if test="string-length(date:second-in-minute($date)) = 1">0</xsl:if>
                <xsl:value-of select="date:second-in-minute($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'U'">
                <xsl:value-of select="date:week-in-year($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'w'">
                <xsl:value-of select="date:day-in-week($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'x'">
                <xsl:value-of select="date:date($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'X'">
                <xsl:value-of select="date:time($date)"/>
              </xsl:when>
              <xsl:when test="$token = 'Y'">
                <xsl:value-of select="date:year($date)"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$token"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:for-each>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>
          Timestamp processing requires an XSLT processor with support
          for the EXSLT node-set() function.
        </xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>