Ignore:
Timestamp:
Jul 21, 2007, 8:07:11 AM (17 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
master
Children:
a6966fa
Parents:
3ca2208
Message:

Merged r8226 from new-xsl branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/common/pi.xsl

    r3ca2208 r00b1e11  
    11<?xml version='1.0'?>
    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"
    8                 version='1.0'>
     2<xsl:stylesheet
     3  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     4  xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
     5  xmlns:date="http://exslt.org/dates-and-times"
     6  xmlns:exsl="http://exslt.org/common"
     7  xmlns:xlink="http://www.w3.org/1999/xlink"
     8  exclude-result-prefixes="doc date exsl"
     9  extension-element-prefixes="date exsl"
     10  version='1.0'>
    911
    1012<!-- ********************************************************************
     
    1618     copyright and other information.
    1719
    18      This file contains general templates for processing processing
    19      instructions common to both the HTML and FO versions of the
    20      DocBook stylesheets.
    2120     ******************************************************************** -->
    2221
    23 <!-- Process PIs also on title pages -->
    24 <xsl:template match="processing-instruction()" mode="titlepage.mode">
    25   <xsl:apply-templates select="."/>
    26 </xsl:template>
    27 
    28 <xsl:template match="processing-instruction('dbtimestamp')">
     22<doc:reference xmlns=""><info><title>Common Processing Instruction Reference</title>
     23    <releaseinfo role="meta">
     24      $Id$
     25    </releaseinfo>
     26  </info>
     27  <partintro id="partintro">
     28    <title>Introduction</title>
     29    <para>This is generated reference documentation for all
     30      user-specifiable processing instructions (PIs) in the
     31      “common” part of the DocBook XSL stylesheets.
     32      <note>
     33        <para>You add these PIs at particular points in a document to
     34          cause specific “exceptions” to formatting/output behavior. To
     35          make global changes in formatting/output behavior across an
     36          entire document, it’s better to do it by setting an
     37          appropriate stylesheet parameter (if there is one).</para>
     38      </note>
     39    </para>
     40  </partintro>
     41</doc:reference>
     42
     43<!-- ==================================================================== -->
     44<doc:pi name="dbchoice_choice" xmlns="">
     45  <refpurpose>Generates a localized choice separator</refpurpose>
     46  <refdescription id="select.choice.separator-desc">
     47    <para>Use the <tag class="xmlpi">dbchoice choice</tag> PI to
     48      generate an appropriate localized “choice” separator (for
     49      example, <literal>and</literal> or <literal>or</literal>)
     50      before the final item in an inline <tag>simplelist</tag></para>
     51    <warning>
     52      <para>This PI is a less-than-ideal hack; support for it may
     53        disappear in the future (particularly if and when a more
     54        appropriate means for marking up "choice" lists becomes
     55        available in DocBook).</para>
     56    </warning>
     57  </refdescription>
     58  <refsynopsisdiv>
     59    <synopsis><tag class="xmlpi">dbchoice choice="and"|"or"|<replaceable>string</replaceable>"</tag></synopsis>
     60  </refsynopsisdiv>
     61  <refparameter>
     62    <variablelist>
     63      <varlistentry><term>choice="and"</term>
     64        <listitem>
     65          <para>generates a localized <literal>and</literal> separator</para>
     66        </listitem>
     67      </varlistentry>
     68      <varlistentry><term>choice="or"</term>
     69        <listitem>
     70          <para>generates a localized <literal>or</literal> separator</para>
     71        </listitem>
     72      </varlistentry>
     73      <varlistentry><term>choice="<replaceable>string</replaceable>"</term>
     74        <listitem>
     75          <para>generates a literal <replaceable>string</replaceable> separator</para>
     76        </listitem>
     77      </varlistentry>
     78    </variablelist>
     79  </refparameter>
     80</doc:pi>
     81<xsl:template name="pi.dbchoice_choice">
     82  <xsl:param name="node" select="."/>
     83  <xsl:call-template name="pi-attribute">
     84    <xsl:with-param name="pis" select="$node/processing-instruction('dbchoice')"/>
     85    <xsl:with-param name="attribute">choice</xsl:with-param>
     86  </xsl:call-template>
     87</xsl:template>
     88
     89<doc:pi name="dbtimestamp" xmlns="">
     90  <refpurpose>Inserts a date timestamp</refpurpose>
     91  <refdescription>
     92    <para>Use the <tag>dbtimestamp</tag> PI at any point in a
     93      source document to cause a date timestamp (a formatted
     94      string representing the current date and time) to be
     95      inserted in output of the document.</para>
     96  </refdescription>
     97  <refsynopsisdiv>
     98    <synopsis><tag class="xmlpi">dbtimestamp format="<replaceable>formatstring</replaceable>" [padding="0"|"1"]</tag></synopsis>
     99  </refsynopsisdiv>
     100  <refparameter>
     101    <variablelist>
     102      <varlistentry><term>format="<replaceable>formatstring</replaceable>"</term>
     103        <listitem>
     104          <para>Specifies format in which the date and time are
     105            output</para>
     106        <note>
     107          <para>For details of the content of the format string,
     108            see <link role="tcg" xlink:href="Datetime.html"
     109              >Date and time</link>.</para>
     110        </note>
     111        </listitem>
     112      </varlistentry>
     113      <varlistentry><term>padding="0"|"1"</term>
     114        <listitem>
     115          <para>Specifies padding behavior; if non-zero, padding is is added</para>
     116        </listitem>
     117      </varlistentry>
     118    </variablelist>
     119  </refparameter>
     120</doc:pi>
     121<xsl:template name="pi.dbtimestamp">
    29122  <xsl:variable name="format">
    30123    <xsl:variable name="pi-format">
     
    45138      </xsl:otherwise>
    46139    </xsl:choose>
    47   </xsl:variable> 
    48 
     140  </xsl:variable>
    49141  <xsl:variable name="padding">
    50142    <xsl:variable name="pi-padding">
     
    61153    </xsl:choose>
    62154  </xsl:variable>
    63 
    64155  <xsl:variable name="date">
    65156    <xsl:choose>
     
    73164    </xsl:choose>
    74165  </xsl:variable>
    75 
    76166  <xsl:choose>
    77167    <xsl:when test="function-available('date:date-time') or
    78                     function-available('date:dateTime')">
     168      function-available('date:dateTime')">
    79169      <xsl:call-template name="datetime.format">
    80170        <xsl:with-param name="date" select="$date"/>
     
    89179    </xsl:otherwise>
    90180  </xsl:choose>
    91 
     181</xsl:template>
     182
     183<doc:pi name="dbtex_delims" xmlns="">
     184  <refpurpose>Generates delimiters around embedded TeX equations
     185    in output</refpurpose>
     186  <refdescription>
     187    <para>Use the <tag class="xmlpi">dbtex delims</tag> PI as a
     188      child of a <tag>textobject</tag> containing embedded TeX
     189      markup, to cause that markup to be surrounded by
     190      <literal>$</literal> delimiter characters in output.</para>
     191  </refdescription>
     192  <refsynopsisdiv>
     193    <synopsis><tag class="xmlpi">dbtex delims="no"|"yes"</tag></synopsis>
     194  </refsynopsisdiv>
     195  <refparameter>
     196    <variablelist>
     197      <varlistentry><term>dbtex delims="no"|"yes"</term>
     198        <listitem>
     199          <para>Specifies whether delimiters are output</para>
     200        </listitem>
     201      </varlistentry>
     202    </variablelist>
     203  </refparameter>
     204  <refsee role="params">
     205    <para><parameter>tex.math.delims</parameter></para>
     206  </refsee>
     207  <refsee role="tcg">
     208    <para><link role="tcg"
     209        xlink:href="TexMath.html"
     210        >DBTeXMath</link></para>
     211  </refsee>
     212</doc:pi>
     213<xsl:template name="pi.dbtex_delims">
     214  <xsl:param name="node" select="."/>
     215  <xsl:call-template name="pi-attribute">
     216    <xsl:with-param name="pis" select="$node/processing-instruction('dbtex')"/>
     217    <xsl:with-param name="attribute" select="'delims'"/>
     218  </xsl:call-template>
     219</xsl:template>
     220
     221<!-- ==================================================================== -->
     222
     223<xsl:template match="processing-instruction()" mode="titlepage.mode">
     224  <!-- * Als process PIs on title pages -->
     225  <xsl:apply-templates select="."/>
     226</xsl:template>
     227
     228<xsl:template match="processing-instruction('dbtimestamp')">
     229  <xsl:call-template name="pi.dbtimestamp"/>
    92230</xsl:template>
    93231
     
    96234  <xsl:param name="format"/>
    97235  <xsl:param name="padding" select="1"/>
    98  
    99236  <xsl:if test="$format != ''">
    100237    <!-- replace any whitespace in the format string with a non-breaking space -->
    101238    <xsl:variable name="format-nbsp"
    102                   select="translate($format,
    103                           '&#x20;&#x9;&#xd;&#xa;',
    104                           '&#xa0;&#xa0;&#xa0;&#xa0;')"/>
     239      select="translate($format,
     240      '&#x20;&#x9;&#xd;&#xa;',
     241      '&#xa0;&#xa0;&#xa0;&#xa0;')"/>
    105242    <xsl:variable name="tokenized-format-string">
    106243      <xsl:call-template name="str.tokenize.keep.delimiters">
    107         <xsl:with-param name="string" select="$format-nbsp"/>
    108         <xsl:with-param name="delimiters" select="'&#xa0;,./-()[]:'"/>
     244        <xsl:with-param name="string" select="$format-nbsp"/>
     245        <xsl:with-param name="delimiters" select="'&#xa0;,./-()[]:'"/>
    109246      </xsl:call-template>
    110247    </xsl:variable>
    111 
    112   <xsl:choose>
    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="."/>
    121         </xsl:variable>
    122         <!-- Restore context node -->
    123         <xsl:for-each select="$context">
    124           <xsl:choose>
    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)"/>
    129               </xsl:call-template>
    130             </xsl:when>
    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)"/>
    135               </xsl:call-template>
    136             </xsl:when>
    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)"/>
    141               </xsl:call-template>
    142             </xsl:when>
    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)"/>
    147             </xsl:when>
    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)"/>
    152               </xsl:call-template>
    153             </xsl:when>
    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)"/>
    158             </xsl:when>
    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)"/>
    162             </xsl:when>
    163             <xsl:when test="$token = 'j'">
    164               <xsl:value-of select="date:day-in-year($date)"/>
    165             </xsl:when>
    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)"/>
    169             </xsl:when>
    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)"/>
    173             </xsl:when>
    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)"/>
    177             </xsl:when>
    178             <xsl:when test="$token = 'U'">
    179               <xsl:value-of select="date:week-in-year($date)"/>
    180             </xsl:when>
    181             <xsl:when test="$token = 'w'">
    182               <xsl:value-of select="date:day-in-week($date)"/>
    183             </xsl:when>
    184             <xsl:when test="$token = 'x'">
    185               <xsl:value-of select="date:date($date)"/>
    186             </xsl:when>
    187             <xsl:when test="$token = 'X'">
    188               <xsl:value-of select="date:time($date)"/>
    189             </xsl:when>
    190             <xsl:when test="$token = 'Y'">
    191               <xsl:value-of select="date:year($date)"/>
    192             </xsl:when>
    193             <xsl:otherwise>
    194               <xsl:value-of select="$token"/>
    195             </xsl:otherwise>
    196           </xsl:choose>
     248    <xsl:choose>
     249      <!-- include extra test for Xalan quirk -->
     250      <xsl:when test="function-available('exsl:node-set') or
     251        contains(system-property('xsl:vendor'),'Apache Software Foundation')">
     252        <!-- We must preserve context node in order to get valid language -->
     253        <xsl:variable name="context" select="."/>
     254        <xsl:for-each select="exsl:node-set($tokenized-format-string)/node()">
     255          <xsl:variable name="token">
     256            <xsl:value-of select="."/>
     257          </xsl:variable>
     258          <!-- Restore context node -->
     259          <xsl:for-each select="$context">
     260            <xsl:choose>
     261              <xsl:when test="$token = 'a'">
     262                <xsl:call-template name="gentext.template">
     263                  <xsl:with-param name="context" select="'datetime-abbrev'"/>
     264                  <xsl:with-param name="name" select="date:day-abbreviation($date)"/>
     265                </xsl:call-template>
     266              </xsl:when>
     267              <xsl:when test="$token = 'A'">
     268                <xsl:call-template name="gentext.template">
     269                  <xsl:with-param name="context" select="'datetime-full'"/>
     270                  <xsl:with-param name="name" select="date:day-name($date)"/>
     271                </xsl:call-template>
     272              </xsl:when>
     273              <xsl:when test="$token = 'b'">
     274                <xsl:call-template name="gentext.template">
     275                  <xsl:with-param name="context" select="'datetime-abbrev'"/>
     276                  <xsl:with-param name="name" select="date:month-abbreviation($date)"/>
     277                </xsl:call-template>
     278              </xsl:when>
     279              <xsl:when test="$token = 'c'">
     280                <xsl:value-of select="date:date($date)"/>
     281                <xsl:text> </xsl:text>
     282                <xsl:value-of select="date:time($date)"/>
     283              </xsl:when>
     284              <xsl:when test="$token = 'B'">
     285                <xsl:call-template name="gentext.template">
     286                  <xsl:with-param name="context" select="'datetime-full'"/>
     287                  <xsl:with-param name="name" select="date:month-name($date)"/>
     288                </xsl:call-template>
     289              </xsl:when>
     290              <xsl:when test="$token = 'd'">
     291                <xsl:if test="$padding = 1 and
     292                  string-length(date:day-in-month($date)) = 1">0</xsl:if>
     293                <xsl:value-of select="date:day-in-month($date)"/>
     294              </xsl:when>
     295              <xsl:when test="$token = 'H'">
     296                <xsl:if test="$padding = 1 and string-length(date:hour-in-day($date)) = 1">0</xsl:if>
     297                <xsl:value-of select="date:hour-in-day($date)"/>
     298              </xsl:when>
     299              <xsl:when test="$token = 'j'">
     300                <xsl:value-of select="date:day-in-year($date)"/>
     301              </xsl:when>
     302              <xsl:when test="$token = 'm'">
     303                <xsl:if test="$padding = 1 and string-length(date:month-in-year($date)) = 1">0</xsl:if>
     304                <xsl:value-of select="date:month-in-year($date)"/>
     305              </xsl:when>
     306              <xsl:when test="$token = 'M'">
     307                <xsl:if test="string-length(date:minute-in-hour($date)) = 1">0</xsl:if>
     308                <xsl:value-of select="date:minute-in-hour($date)"/>
     309              </xsl:when>
     310              <xsl:when test="$token = 'S'">
     311                <xsl:if test="string-length(date:second-in-minute($date)) = 1">0</xsl:if>
     312                <xsl:value-of select="date:second-in-minute($date)"/>
     313              </xsl:when>
     314              <xsl:when test="$token = 'U'">
     315                <xsl:value-of select="date:week-in-year($date)"/>
     316              </xsl:when>
     317              <xsl:when test="$token = 'w'">
     318                <xsl:value-of select="date:day-in-week($date)"/>
     319              </xsl:when>
     320              <xsl:when test="$token = 'x'">
     321                <xsl:value-of select="date:date($date)"/>
     322              </xsl:when>
     323              <xsl:when test="$token = 'X'">
     324                <xsl:value-of select="date:time($date)"/>
     325              </xsl:when>
     326              <xsl:when test="$token = 'Y'">
     327                <xsl:value-of select="date:year($date)"/>
     328              </xsl:when>
     329              <xsl:otherwise>
     330                <xsl:value-of select="$token"/>
     331              </xsl:otherwise>
     332            </xsl:choose>
     333          </xsl:for-each>
    197334        </xsl:for-each>
    198       </xsl:for-each>
    199     </xsl:when>
    200     <xsl:otherwise>
    201       <xsl:message>
    202         Timestamp processing requires an XSLT processor with support
    203         for the EXSLT node-set() function.
    204       </xsl:message>
    205     </xsl:otherwise>
    206   </xsl:choose>
     335      </xsl:when>
     336      <xsl:otherwise>
     337        <xsl:message>
     338          Timestamp processing requires an XSLT processor with support
     339          for the EXSLT node-set() function.
     340        </xsl:message>
     341      </xsl:otherwise>
     342    </xsl:choose>
    207343  </xsl:if>
    208 
    209344</xsl:template>
    210345
Note: See TracChangeset for help on using the changeset viewer.