Documentation Tools

Changeset 270


Ignore:
Timestamp:
02/19/08 17:21:15 (4 years ago)
Author:
kate
Message:

Split into smaller files.

Location:
branches/modules/modules/docbook-simple/v1.1/xhtml-strict/1.0
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/modules/modules/docbook-simple/v1.1/xhtml-strict/1.0/main.xsl

    r269 r270  
    22<!DOCTYPE xsl:stylesheet [ 
    33        <!ENTITY nbsp "&#xA0;"> 
    4         <!ENTITY sect "&#xA7;"> 
    54]> 
    65 
     
    98        xmlns="http://www.w3.org/1999/xhtml"> 
    109 
     10        <!-- 
     11                Main interface. 
     12 
     13                $Id$ 
     14        --> 
     15 
     16 
     17        <!-- 
     18                TODO perhaps each imported stylesheet should only contain mode="" attributes? 
     19                Is that too restrictive? 
     20        --> 
     21        <xsl:import href="toc.xsl"/> 
     22        <xsl:import href="title.xsl"/> 
     23 
    1124        <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
    1225                doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
    1326                encoding="utf-8" indent="yes"/> 
    1427 
    15 <!-- TODO to be done in the framework --> 
     28<!-- TODO to be done in the framework; perhaps the python can automatically include this --> 
    1629<!-- 
    1730<xsl:template match="*"> 
     
    8295TODO: attributes for everything. e.g. @lang, @revisionflag etc 
    8396 
     97TODO: normalise space. 
     98 
    8499--> 
    85100 
     
    116131 
    117132                        <head> 
    118                                 <xsl:choose> 
    119                                         <xsl:when test="title"> 
    120                                                 <title> 
    121                                                         <xsl:apply-templates select="title"/> 
    122                                                 </title> 
    123                                         </xsl:when> 
    124  
    125                                         <xsl:when test="articleinfo/title"> 
    126                                                 <title> 
    127                                                         <xsl:apply-templates select="articleinfo/title"/> 
    128                                                 </title> 
    129                                         </xsl:when> 
    130                                 </xsl:choose> 
     133                                <xsl:call-template name="title-head"/> 
    131134 
    132135                                <xsl:if test="$option-stylesheet"> 
     
    140143 
    141144                        <body> 
    142                                 <xsl:choose> 
    143                                         <xsl:when test="articleinfo/title"> 
    144                                                 <h1> 
    145                                                         <xsl:apply-templates select="articleinfo/title"/> 
    146                                                 </h1> 
    147                                         </xsl:when> 
    148  
    149                                         <xsl:when test="title"> 
    150                                                 <h1> 
    151                                                         <xsl:apply-templates select="title"/> 
    152                                                 </h1> 
    153                                         </xsl:when> 
    154                                 </xsl:choose> 
     145                                <xsl:call-template name="title-body"/> 
    155146 
    156147                                <xsl:apply-templates select="articleinfo/author"/> 
     
    160151                                <xsl:apply-templates select="articleinfo/abstract"/> 
    161152 
    162                                 <xsl:if test="section|appendix|bibliography"> 
    163                                         <div class="toc"> 
    164                                                 <h2> 
    165                                                         <xsl:text>Table of Contents</xsl:text> 
    166                                                 </h2> 
    167  
    168                                                 <ol> 
    169                                                         <xsl:apply-templates select="section|appendix|bibliography" mode="toc"/> 
    170                                                 </ol> 
    171                                         </div> 
    172                                 </xsl:if> 
     153                                <xsl:call-template name="toc"/> 
    173154 
    174155                                <xsl:apply-templates select="section|appendix|bibliography 
     
    180161        </xsl:template> 
    181162 
    182         <!-- 
    183                 Produce a linkable id from a given non-root <title> tag. 
    184                 This is suitable for use as a HTML anchor. 
    185         --> 
    186         <xsl:template name="link-title"> 
    187                 <xsl:choose> 
    188                         <xsl:when test="ancestor::bibliography"> 
    189                                 <xsl:text>bib-</xsl:text> 
    190                                 <xsl:number count="bibliography" level="single" format="1"/> 
    191                         </xsl:when> 
    192  
    193                         <xsl:when test="ancestor::appendix"> 
    194                                 <!-- No prefix --> 
    195                         </xsl:when> 
    196  
    197                         <xsl:when test="ancestor::section"> 
    198                                 <!-- TODO is &sect; legal for # links in HTML? --> 
    199                                 <xsl:text>&sect;</xsl:text> 
    200                         </xsl:when> 
    201  
    202                         <xsl:otherwise> 
    203                                 <xsl:message terminate="yes"> 
    204                                         <xsl:text>Unrecognised link title ancestor</xsl:text> 
    205                                 </xsl:message> 
    206                         </xsl:otherwise> 
    207                 </xsl:choose> 
    208  
    209                 <xsl:call-template name="number-title"/> 
    210         </xsl:template> 
    211  
    212         <!-- 
    213                 Output a number-title prefix, for numbering headings of sections. 
    214                 Outputs nothing if the output-titlenumber option is false. 
    215  
    216                 Call from inside a title. 
    217         --> 
    218         <xsl:template name="titlenumber-title"> 
    219                 <xsl:if test="$option-titlenumber"> 
    220                         <xsl:call-template name="number-title"/> 
    221                         <xsl:text>&nbsp;</xsl:text> 
    222                 </xsl:if> 
    223         </xsl:template> 
    224  
    225         <!-- 
    226                 Enumerate a title (not article/title). No trailing space. 
    227         --> 
    228         <xsl:template name="number-title"> 
    229                 <xsl:choose> 
    230                         <xsl:when test="ancestor::appendix"> 
    231                                 <xsl:number count="appendix" level="single" format="A"/> 
    232  
    233                                 <xsl:if test="ancestor-or-self::section"> 
    234                                         <xsl:text>.</xsl:text> 
    235                                 </xsl:if> 
    236                         </xsl:when> 
    237  
    238                         <xsl:when test="ancestor::bibliography"> 
    239                                 <!-- We do not enumerate bibliographies --> 
    240                         </xsl:when> 
    241                 </xsl:choose> 
    242  
    243                 <xsl:number count="section" level="multiple" format="1"/> 
    244         </xsl:template> 
    245  
    246         <xsl:template match="section|appendix|bibliography" mode="toc"> 
    247                 <xsl:apply-templates select="title" mode="toc"/> 
    248  
    249                 <ol> 
    250                         <xsl:apply-templates select="section/title" mode="toc"/> 
    251                 </ol> 
    252         </xsl:template> 
    253  
    254         <xsl:template match="section/title|bibliography/title|appendix/title" mode="toc"> 
    255                 <li style="list-style-type: none;"> 
    256                         <xsl:call-template name="titlenumber-title"/> 
    257  
    258                         <a> 
    259                                 <xsl:attribute name="href"> 
    260                                         <xsl:text>#</xsl:text> 
    261                                         <xsl:call-template name="link-title"/> 
    262                                 </xsl:attribute> 
    263  
    264                                 <xsl:apply-templates/> 
    265                         </a> 
    266                 </li> 
    267         </xsl:template> 
    268  
    269163        <xsl:template match="author"> 
    270164                <div class="author"> 
     
    304198        </xsl:template> 
    305199 
    306         <xsl:template match="title"> 
    307                 <a> 
    308                         <xsl:attribute name="name"> 
    309                                 <xsl:call-template name="link-title"/> 
    310                         </xsl:attribute> 
    311                 </a> 
    312  
    313                 <xsl:apply-templates/> 
    314         </xsl:template> 
    315  
    316         <!-- 
    317                 Generate no link for the main article title. 
    318         --> 
    319         <xsl:template match="article/title|articleinfo/title"> 
    320                 <xsl:apply-templates/> 
    321         </xsl:template> 
    322  
    323200        <xsl:template match="section"> 
    324201                <div class="section"> 
     
    328205                                <xsl:apply-templates select="title"/> 
    329206                        </h2> 
     207 
     208                        <xsl:call-template name="toc"/> 
    330209 
    331210                        <xsl:apply-templates select="*[name() != 'title']"/> 
     
    342221                        </h2> 
    343222 
     223                        <xsl:call-template name="toc"/> 
     224 
    344225                        <xsl:apply-templates select="*[name() != 'title']"/> 
    345226                </div> 
  • branches/modules/modules/docbook-simple/v1.1/xhtml-strict/1.0/title.xsl

    r269 r270  
    99        xmlns="http://www.w3.org/1999/xhtml"> 
    1010 
    11         <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
    12                 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
    13                 encoding="utf-8" indent="yes"/> 
     11        <!-- 
     12                Section titles. This includes numbering for sections. 
    1413 
    15 <!-- TODO to be done in the framework --> 
    16 <!-- 
    17 <xsl:template match="*"> 
    18 <xsl:message terminate="yes"> 
    19 <xsl:text>Unrecognised element: </xsl:text> 
    20 <xsl:value-of select="name()"/> 
    21 </xsl:message></xsl:template> 
    22 --> 
     14                $Id$ 
     15        --> 
    2316 
    24 <!-- 
    25 Required: 
    26         footnoteref 
    27         xref 
    28         abbrev 
    29         acronym 
    30         citetitle 
    31         emphasis 
    32         footnote 
    33         phrase 
    34         quote 
    35         trademark 
    36         link 
    37         ulink 
    38         command 
    39         computeroutput 
    40         email 
    41         filename 
    42         literal 
    43         option 
    44         replacable 
    45         systemitem 
    46         userinput 
    47         inlinedmediaobject 
    48         author 
    49         corpauthor 
    50         othercredit 
    51         revhistory 
    52         section 
    53         appendix 
    54         bibliography 
     17        <xsl:template name="title-head"> 
     18                <!-- 
     19                        According to the official docbook xsl, ./title has precidence 
     20                        for the XHTML title, and ./articleinfo/title has precidence for 
     21                        the page title. Goodness knows why two titles exist. 
     22                --> 
    5523 
    56 WIP: 
    57         article 
    58         para 
    59         acronym 
    60         quote 
    61         emphasis 
    62         itemizedlist 
    63         listitem 
    64         abstract 
    65         ulink 
    66         author 
    67     honorific 
    68         firstname 
    69         surname 
    70         lineage 
    71         othername 
    72         affiliation 
    73         authorblurb 
    74         releaseinfo 
     24                <xsl:choose> 
     25                        <xsl:when test="title"> 
     26                                <title> 
     27                                        <xsl:apply-templates select="title"/> 
     28                                </title> 
     29                        </xsl:when> 
    7530 
    76 Done: 
    77         title 
     31                        <xsl:when test="articleinfo/title"> 
     32                                <title> 
     33                                        <xsl:apply-templates select="articleinfo/title"/> 
     34                                </title> 
     35                        </xsl:when> 
     36                </xsl:choose> 
     37        </xsl:template> 
    7838 
    79 Won't implement: 
    80         articleinfo (its contents are used as and when required) 
     39        <xsl:template name="title-body"> 
     40                <xsl:choose> 
     41                        <xsl:when test="articleinfo/title"> 
     42                                <h1> 
     43                                        <xsl:apply-templates select="articleinfo/title"/> 
     44                                </h1> 
     45                        </xsl:when> 
    8146 
    82 TODO: attributes for everything. e.g. @lang, @revisionflag etc 
     47                        <xsl:when test="title"> 
     48                                <h1> 
     49                                        <xsl:apply-templates select="title"/> 
     50                                </h1> 
     51                        </xsl:when> 
     52                </xsl:choose> 
     53        </xsl:template> 
    8354 
    84 --> 
    85  
    86         <!-- Options --> 
    87         <!-- TODO enumerate these somewhere globally: 
    88                 1. We should assert that our option exists (the python can do this) 
    89                 2. Documentation 
    90                 3. To reduce module-specific options 
    91         --> 
    92         <!-- TODO split up into smaller files; toc can go first --> 
    93         <xsl:param name="option-stylesheet"/> 
    94  
    95         <!-- 
    96                 Enable/disable numbering of titles for sections and such. 
    97         --> 
    98         <xsl:param name="option-titlenumber" select="1"/>       <!-- boolean: 1/0 --> 
    99  
    100         <!-- TODO add toc-depth option (0 for no toc) --> 
    101  
    102  
    103         <!-- XXX missing --> 
    104         <xsl:template match="xref"/> 
    105         <xsl:template match="figure"/> 
    106         <xsl:template match="bibliography"/> 
    107  
    108         <xsl:template match="article"> 
    109                 <html> 
    110  
    111                         <!-- 
    112                                 According to the official docbook xsl, ./title has precidence 
    113                                 for the XHTML title, and ./articleinfo/title has precidence for 
    114                                 the page title. Goodness knows why two titles exist. 
    115                         --> 
    116  
    117                         <head> 
    118                                 <xsl:choose> 
    119                                         <xsl:when test="title"> 
    120                                                 <title> 
    121                                                         <xsl:apply-templates select="title"/> 
    122                                                 </title> 
    123                                         </xsl:when> 
    124  
    125                                         <xsl:when test="articleinfo/title"> 
    126                                                 <title> 
    127                                                         <xsl:apply-templates select="articleinfo/title"/> 
    128                                                 </title> 
    129                                         </xsl:when> 
    130                                 </xsl:choose> 
    131  
    132                                 <xsl:if test="$option-stylesheet"> 
    133                                         <link rel="stylesheet" type="text/css"> 
    134                                                 <xsl:attribute name="href"> 
    135                                                         <xsl:value-of select="$option-stylesheet"/> 
    136                                                 </xsl:attribute> 
    137                                         </link> 
    138                                 </xsl:if> 
    139                         </head> 
    140  
    141                         <body> 
    142                                 <xsl:choose> 
    143                                         <xsl:when test="articleinfo/title"> 
    144                                                 <h1> 
    145                                                         <xsl:apply-templates select="articleinfo/title"/> 
    146                                                 </h1> 
    147                                         </xsl:when> 
    148  
    149                                         <xsl:when test="title"> 
    150                                                 <h1> 
    151                                                         <xsl:apply-templates select="title"/> 
    152                                                 </h1> 
    153                                         </xsl:when> 
    154                                 </xsl:choose> 
    155  
    156                                 <xsl:apply-templates select="articleinfo/author"/> 
    157  
    158                                 <xsl:apply-templates select="articleinfo/releaseinfo"/> 
    159  
    160                                 <xsl:apply-templates select="articleinfo/abstract"/> 
    161  
    162                                 <xsl:if test="section|appendix|bibliography"> 
    163                                         <div class="toc"> 
    164                                                 <h2> 
    165                                                         <xsl:text>Table of Contents</xsl:text> 
    166                                                 </h2> 
    167  
    168                                                 <ol> 
    169                                                         <xsl:apply-templates select="section|appendix|bibliography" mode="toc"/> 
    170                                                 </ol> 
    171                                         </div> 
    172                                 </xsl:if> 
    173  
    174                                 <xsl:apply-templates select="section|appendix|bibliography 
    175                                         |itemizedlist|orderedlist|variablelist|note|literallayout 
    176                                         |programlisting|para|blockquote|mediaobject|informaltable 
    177                                         |example|figure|table|sidebar|abstract|authorblurb|epigraph"/> 
    178                         </body> 
    179                 </html> 
    180         </xsl:template> 
     55        <!-- TODO consistenise the names for templates per xsl file (e.g. prefix all these "title-") --> 
     56        <!-- TODO also prefix private templates _title- --> 
    18157 
    18258        <!-- 
     
    244120        </xsl:template> 
    245121 
    246         <xsl:template match="section|appendix|bibliography" mode="toc"> 
    247                 <xsl:apply-templates select="title" mode="toc"/> 
    248  
    249                 <ol> 
    250                         <xsl:apply-templates select="section/title" mode="toc"/> 
    251                 </ol> 
    252         </xsl:template> 
    253  
    254         <xsl:template match="section/title|bibliography/title|appendix/title" mode="toc"> 
    255                 <li style="list-style-type: none;"> 
    256                         <xsl:call-template name="titlenumber-title"/> 
    257  
    258                         <a> 
    259                                 <xsl:attribute name="href"> 
    260                                         <xsl:text>#</xsl:text> 
    261                                         <xsl:call-template name="link-title"/> 
    262                                 </xsl:attribute> 
    263  
    264                                 <xsl:apply-templates/> 
    265                         </a> 
    266                 </li> 
    267         </xsl:template> 
    268  
    269         <xsl:template match="author"> 
    270                 <div class="author"> 
    271                         <xsl:apply-templates/> 
    272                 </div> 
    273         </xsl:template> 
    274  
    275         <xsl:template match="honorific|firstname|surname|lineage|othername|affiliation|authorblurb"> 
    276                 <xsl:apply-templates/> 
    277         </xsl:template> 
    278  
    279         <xsl:template match="affiliation"> 
    280                 <xsl:if test="*"> 
    281                         <xsl:text>, </xsl:text> 
    282                         <xsl:apply-templates/> 
    283                 </xsl:if> 
    284         </xsl:template> 
    285  
    286         <xsl:template match="jobtitle|orgname"> 
    287                 <xsl:apply-templates/> 
    288         </xsl:template> 
    289  
    290         <xsl:template match="releaseinfo"> 
    291                 <div class="releaseinfo"> 
    292                         <xsl:apply-templates/> 
    293                 </div> 
    294         </xsl:template> 
    295  
    296         <xsl:template match="abstract"> 
    297                 <div class="abstract"> 
    298                         <h2> 
    299                                 <xsl:text>Abstract</xsl:text> 
    300                         </h2> 
    301  
    302                         <xsl:apply-templates/> 
    303                 </div> 
    304         </xsl:template> 
    305  
     122        <!-- 
     123                Titles by default want an anchor so that they may be linked to. 
     124        --> 
    306125        <xsl:template match="title"> 
    307126                <a> 
     
    321140        </xsl:template> 
    322141 
    323         <xsl:template match="section"> 
    324                 <div class="section"> 
    325                         <h2> 
    326                                 <xsl:call-template name="titlenumber-title"/> 
    327  
    328                                 <xsl:apply-templates select="title"/> 
    329                         </h2> 
    330  
    331                         <xsl:apply-templates select="*[name() != 'title']"/> 
    332                 </div> 
    333         </xsl:template> 
    334  
    335         <xsl:template match="appendix"> 
    336                 <div class="appendix"> 
    337                         <h2> 
    338                                 <xsl:text>Appendix </xsl:text> 
    339                                 <xsl:number count="appendix" level="multiple" format="A."/> 
    340                                 <xsl:text>&nbsp;</xsl:text> 
    341                                 <xsl:apply-templates select="title"/> 
    342                         </h2> 
    343  
    344                         <xsl:apply-templates select="*[name() != 'title']"/> 
    345                 </div> 
    346         </xsl:template> 
    347  
    348         <xsl:template match="para"> 
    349                 <p> 
    350                         <xsl:apply-templates/> 
    351                 </p> 
    352         </xsl:template> 
    353  
    354         <xsl:template match="acronym"> 
    355                 <acronym> 
    356                         <xsl:apply-templates/> 
    357                 </acronym> 
    358         </xsl:template> 
    359  
    360         <xsl:template match="quote"> 
    361                 <q> 
    362                         <xsl:apply-templates/> 
    363                 </q> 
    364         </xsl:template> 
    365  
    366         <xsl:template match="emphasis"> 
    367                 <em> 
    368                         <xsl:apply-templates/> 
    369                 </em> 
    370         </xsl:template> 
    371  
    372         <xsl:template match="ulink"> 
    373                 <xsl:if test="not(@url)"> 
    374                         <xsl:message terminate="yes"> 
    375                                 <xsl:text>Missing required attribute @url for element ulink</xsl:text> 
    376                         </xsl:message> 
    377                 </xsl:if> 
    378  
    379                 <a href="{@url}"> 
    380                         <xsl:choose> 
    381                                 <!-- explicit link text, if present --> 
    382                                 <xsl:when test="*|text()"> 
    383                                         <xsl:apply-templates/> 
    384                                 </xsl:when> 
    385  
    386                                 <!-- default to the URL --> 
    387                                 <xsl:otherwise> 
    388                                         <xsl:value-of select="@url"/> 
    389                                 </xsl:otherwise> 
    390                         </xsl:choose> 
    391                 </a> 
    392         </xsl:template> 
    393  
    394         <xsl:template match="itemizedlist"> 
    395                 <ul> 
    396                         <xsl:apply-templates/> 
    397                 </ul> 
    398         </xsl:template> 
    399  
    400         <xsl:template match="listitem"> 
    401                 <li> 
    402                         <xsl:apply-templates/> 
    403                 </li> 
    404         </xsl:template> 
    405  
    406         <xsl:template match="citetitle"> 
    407                 <cite> 
    408                         <xsl:apply-templates/> 
    409                 </cite> 
    410         </xsl:template> 
    411  
    412         <xsl:template match="literal"> 
    413                 <tt> 
    414                         <xsl:apply-templates/> 
    415                 </tt> 
    416         </xsl:template> 
    417  
    418142</xsl:stylesheet> 
    419143 
  • branches/modules/modules/docbook-simple/v1.1/xhtml-strict/1.0/toc.xsl

    r269 r270  
    11<?xml version="1.0"?> 
    2 <!DOCTYPE xsl:stylesheet [ 
    3         <!ENTITY nbsp "&#xA0;"> 
    4         <!ENTITY sect "&#xA7;"> 
    5 ]> 
    62 
    73<xsl:stylesheet version="1.0" 
     
    95        xmlns="http://www.w3.org/1999/xhtml"> 
    106 
    11         <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
    12                 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
    13                 encoding="utf-8" indent="yes"/> 
     7        <!-- 
     8                Table of Contents. 
    149 
    15 <!-- TODO to be done in the framework --> 
    16 <!-- 
    17 <xsl:template match="*"> 
    18 <xsl:message terminate="yes"> 
    19 <xsl:text>Unrecognised element: </xsl:text> 
    20 <xsl:value-of select="name()"/> 
    21 </xsl:message></xsl:template> 
    22 --> 
    23  
    24 <!-- 
    25 Required: 
    26         footnoteref 
    27         xref 
    28         abbrev 
    29         acronym 
    30         citetitle 
    31         emphasis 
    32         footnote 
    33         phrase 
    34         quote 
    35         trademark 
    36         link 
    37         ulink 
    38         command 
    39         computeroutput 
    40         email 
    41         filename 
    42         literal 
    43         option 
    44         replacable 
    45         systemitem 
    46         userinput 
    47         inlinedmediaobject 
    48         author 
    49         corpauthor 
    50         othercredit 
    51         revhistory 
    52         section 
    53         appendix 
    54         bibliography 
    55  
    56 WIP: 
    57         article 
    58         para 
    59         acronym 
    60         quote 
    61         emphasis 
    62         itemizedlist 
    63         listitem 
    64         abstract 
    65         ulink 
    66         author 
    67     honorific 
    68         firstname 
    69         surname 
    70         lineage 
    71         othername 
    72         affiliation 
    73         authorblurb 
    74         releaseinfo 
    75  
    76 Done: 
    77         title 
    78  
    79 Won't implement: 
    80         articleinfo (its contents are used as and when required) 
    81  
    82 TODO: attributes for everything. e.g. @lang, @revisionflag etc 
    83  
    84 --> 
    85  
    86         <!-- Options --> 
    87         <!-- TODO enumerate these somewhere globally: 
    88                 1. We should assert that our option exists (the python can do this) 
    89                 2. Documentation 
    90                 3. To reduce module-specific options 
     10                $Id$ 
    9111        --> 
    92         <!-- TODO split up into smaller files; toc can go first --> 
    93         <xsl:param name="option-stylesheet"/> 
    9412 
    9513        <!-- 
    96                 Enable/disable numbering of titles for sections and such. 
     14                Call from somewhere with section|appendix|bibliography children for 
     15                which a TOC is to be generated. 
    9716        --> 
    98         <xsl:param name="option-titlenumber" select="1"/>       <!-- boolean: 1/0 --> 
    99  
    100         <!-- TODO add toc-depth option (0 for no toc) --> 
    101  
    102  
    103         <!-- XXX missing --> 
    104         <xsl:template match="xref"/> 
    105         <xsl:template match="figure"/> 
    106         <xsl:template match="bibliography"/> 
    107  
    108         <xsl:template match="article"> 
    109                 <html> 
    110  
    111                         <!-- 
    112                                 According to the official docbook xsl, ./title has precidence 
    113                                 for the XHTML title, and ./articleinfo/title has precidence for 
    114                                 the page title. Goodness knows why two titles exist. 
    115                         --> 
    116  
    117                         <head> 
    118                                 <xsl:choose> 
    119                                         <xsl:when test="title"> 
    120                                                 <title> 
    121                                                         <xsl:apply-templates select="title"/> 
    122                                                 </title> 
    123                                         </xsl:when> 
    124  
    125                                         <xsl:when test="articleinfo/title"> 
    126                                                 <title> 
    127                                                         <xsl:apply-templates select="articleinfo/title"/> 
    128                                                 </title> 
    129                                         </xsl:when> 
    130                                 </xsl:choose> 
    131  
    132                                 <xsl:if test="$option-stylesheet"> 
    133                                         <link rel="stylesheet" type="text/css"> 
    134                                                 <xsl:attribute name="href"> 
    135                                                         <xsl:value-of select="$option-stylesheet"/> 
    136                                                 </xsl:attribute> 
    137                                         </link> 
    138                                 </xsl:if> 
    139                         </head> 
    140  
    141                         <body> 
    142                                 <xsl:choose> 
    143                                         <xsl:when test="articleinfo/title"> 
    144                                                 <h1> 
    145                                                         <xsl:apply-templates select="articleinfo/title"/> 
    146                                                 </h1> 
    147                                         </xsl:when> 
    148  
    149                                         <xsl:when test="title"> 
    150                                                 <h1> 
    151                                                         <xsl:apply-templates select="title"/> 
    152                                                 </h1> 
    153                                         </xsl:when> 
    154                                 </xsl:choose> 
    155  
    156                                 <xsl:apply-templates select="articleinfo/author"/> 
    157  
    158                                 <xsl:apply-templates select="articleinfo/releaseinfo"/> 
    159  
    160                                 <xsl:apply-templates select="articleinfo/abstract"/> 
    161  
    162                                 <xsl:if test="section|appendix|bibliography"> 
    163                                         <div class="toc"> 
    164                                                 <h2> 
    165                                                         <xsl:text>Table of Contents</xsl:text> 
    166                                                 </h2> 
    167  
    168                                                 <ol> 
    169                                                         <xsl:apply-templates select="section|appendix|bibliography" mode="toc"/> 
    170                                                 </ol> 
    171                                         </div> 
     17        <xsl:template name="toc"> 
     18                <xsl:if test="section|appendix|bibliography"> 
     19                        <div class="toc"> 
     20                                <!-- TODO perhaps make TOC title optional. Perhaps all generated 
     21                                        text ought to come from an associative array for 
     22                                        internationalisation, and be ommitted if not present? --> 
     23                                <!-- TODO perhaps make h2 title optional for TOCs for subsections --> 
     24                                <!-- TODO: undecided here --> 
     25                                <xsl:if test="name() = 'article'"> 
     26                                        <h2> 
     27                                                <xsl:text>Table of Contents</xsl:text> 
     28                                        </h2> 
    17229                                </xsl:if> 
    17330 
    174                                 <xsl:apply-templates select="section|appendix|bibliography 
    175                                         |itemizedlist|orderedlist|variablelist|note|literallayout 
    176                                         |programlisting|para|blockquote|mediaobject|informaltable 
    177                                         |example|figure|table|sidebar|abstract|authorblurb|epigraph"/> 
    178                         </body> 
    179                 </html> 
    180         </xsl:template> 
    181  
    182         <!-- 
    183                 Produce a linkable id from a given non-root <title> tag. 
    184                 This is suitable for use as a HTML anchor. 
    185         --> 
    186         <xsl:template name="link-title"> 
    187                 <xsl:choose> 
    188                         <xsl:when test="ancestor::bibliography"> 
    189                                 <xsl:text>bib-</xsl:text> 
    190                                 <xsl:number count="bibliography" level="single" format="1"/> 
    191                         </xsl:when> 
    192  
    193                         <xsl:when test="ancestor::appendix"> 
    194                                 <!-- No prefix --> 
    195                         </xsl:when> 
    196  
    197                         <xsl:when test="ancestor::section"> 
    198                                 <!-- TODO is &sect; legal for # links in HTML? --> 
    199                                 <xsl:text>&sect;</xsl:text> 
    200                         </xsl:when> 
    201  
    202                         <xsl:otherwise> 
    203                                 <xsl:message terminate="yes"> 
    204                                         <xsl:text>Unrecognised link title ancestor</xsl:text> 
    205                                 </xsl:message> 
    206                         </xsl:otherwise> 
    207                 </xsl:choose> 
    208  
    209                 <xsl:call-template name="number-title"/> 
    210         </xsl:template> 
    211  
    212         <!-- 
    213                 Output a number-title prefix, for numbering headings of sections. 
    214                 Outputs nothing if the output-titlenumber option is false. 
    215  
    216                 Call from inside a title. 
    217         --> 
    218         <xsl:template name="titlenumber-title"> 
    219                 <xsl:if test="$option-titlenumber"> 
    220                         <xsl:call-template name="number-title"/> 
    221                         <xsl:text>&nbsp;</xsl:text> 
     31                                <ol> 
     32                                        <xsl:apply-templates select="section|appendix|bibliography" mode="toc"/> 
     33                                </ol> 
     34                        </div> 
    22235                </xsl:if> 
    223         </xsl:template> 
    224  
    225         <!-- 
    226                 Enumerate a title (not article/title). No trailing space. 
    227         --> 
    228         <xsl:template name="number-title"> 
    229                 <xsl:choose> 
    230                         <xsl:when test="ancestor::appendix"> 
    231                                 <xsl:number count="appendix" level="single" format="A"/> 
    232  
    233                                 <xsl:if test="ancestor-or-self::section"> 
    234                                         <xsl:text>.</xsl:text> 
    235                                 </xsl:if> 
    236                         </xsl:when> 
    237  
    238                         <xsl:when test="ancestor::bibliography"> 
    239                                 <!-- We do not enumerate bibliographies --> 
    240                         </xsl:when> 
    241                 </xsl:choose> 
    242  
    243                 <xsl:number count="section" level="multiple" format="1"/> 
    24436        </xsl:template> 
    24537 
     
    26759        </xsl:template> 
    26860 
    269         <xsl:template match="author"> 
    270                 <div class="author"> 
    271                         <xsl:apply-templates/> 
    272                 </div> 
    273         </xsl:template> 
    274  
    275         <xsl:template match="honorific|firstname|surname|lineage|othername|affiliation|authorblurb"> 
    276                 <xsl:apply-templates/> 
    277         </xsl:template> 
    278  
    279         <xsl:template match="affiliation"> 
    280                 <xsl:if test="*"> 
    281                         <xsl:text>, </xsl:text> 
    282                         <xsl:apply-templates/> 
    283                 </xsl:if> 
    284         </xsl:template> 
    285  
    286         <xsl:template match="jobtitle|orgname"> 
    287                 <xsl:apply-templates/> 
    288         </xsl:template> 
    289  
    290         <xsl:template match="releaseinfo"> 
    291                 <div class="releaseinfo"> 
    292                         <xsl:apply-templates/> 
    293                 </div> 
    294         </xsl:template> 
    295  
    296         <xsl:template match="abstract"> 
    297                 <div class="abstract"> 
    298                         <h2> 
    299                                 <xsl:text>Abstract</xsl:text> 
    300                         </h2> 
    301  
    302                         <xsl:apply-templates/> 
    303                 </div> 
    304         </xsl:template> 
    305  
    306         <xsl:template match="title"> 
    307                 <a> 
    308                         <xsl:attribute name="name"> 
    309                                 <xsl:call-template name="link-title"/> 
    310                         </xsl:attribute> 
    311                 </a> 
    312  
    313                 <xsl:apply-templates/> 
    314         </xsl:template> 
    315  
    316         <!-- 
    317                 Generate no link for the main article title. 
    318         --> 
    319         <xsl:template match="article/title|articleinfo/title"> 
    320                 <xsl:apply-templates/> 
    321         </xsl:template> 
    322  
    323         <xsl:template match="section"> 
    324                 <div class="section"> 
    325                         <h2> 
    326                                 <xsl:call-template name="titlenumber-title"/> 
    327  
    328                                 <xsl:apply-templates select="title"/> 
    329                         </h2> 
    330  
    331                         <xsl:apply-templates select="*[name() != 'title']"/> 
    332                 </div> 
    333         </xsl:template> 
    334  
    335         <xsl:template match="appendix"> 
    336                 <div class="appendix"> 
    337                         <h2> 
    338                                 <xsl:text>Appendix </xsl:text> 
    339                                 <xsl:number count="appendix" level="multiple" format="A."/> 
    340                                 <xsl:text>&nbsp;</xsl:text> 
    341                                 <xsl:apply-templates select="title"/> 
    342                         </h2> 
    343  
    344                         <xsl:apply-templates select="*[name() != 'title']"/> 
    345                 </div> 
    346         </xsl:template> 
    347  
    348         <xsl:template match="para"> 
    349                 <p> 
    350                         <xsl:apply-templates/> 
    351                 </p> 
    352         </xsl:template> 
    353  
    354         <xsl:template match="acronym"> 
    355                 <acronym> 
    356                         <xsl:apply-templates/> 
    357                 </acronym> 
    358         </xsl:template> 
    359  
    360         <xsl:template match="quote"> 
    361                 <q> 
    362                         <xsl:apply-templates/> 
    363                 </q> 
    364         </xsl:template> 
    365  
    366         <xsl:template match="emphasis"> 
    367                 <em> 
    368                         <xsl:apply-templates/> 
    369                 </em> 
    370         </xsl:template> 
    371  
    372         <xsl:template match="ulink"> 
    373                 <xsl:if test="not(@url)"> 
    374                         <xsl:message terminate="yes"> 
    375                                 <xsl:text>Missing required attribute @url for element ulink</xsl:text> 
    376                         </xsl:message> 
    377                 </xsl:if> 
    378  
    379                 <a href="{@url}"> 
    380                         <xsl:choose> 
    381                                 <!-- explicit link text, if present --> 
    382                                 <xsl:when test="*|text()"> 
    383                                         <xsl:apply-templates/> 
    384                                 </xsl:when> 
    385  
    386                                 <!-- default to the URL --> 
    387                                 <xsl:otherwise> 
    388                                         <xsl:value-of select="@url"/> 
    389                                 </xsl:otherwise> 
    390                         </xsl:choose> 
    391                 </a> 
    392         </xsl:template> 
    393  
    394         <xsl:template match="itemizedlist"> 
    395                 <ul> 
    396                         <xsl:apply-templates/> 
    397                 </ul> 
    398         </xsl:template> 
    399  
    400         <xsl:template match="listitem"> 
    401                 <li> 
    402                         <xsl:apply-templates/> 
    403                 </li> 
    404         </xsl:template> 
    405  
    406         <xsl:template match="citetitle"> 
    407                 <cite> 
    408                         <xsl:apply-templates/> 
    409                 </cite> 
    410         </xsl:template> 
    411  
    412         <xsl:template match="literal"> 
    413                 <tt> 
    414                         <xsl:apply-templates/> 
    415                 </tt> 
    416         </xsl:template> 
    417  
    41861</xsl:stylesheet> 
    41962 
Note: See TracChangeset for help on using the changeset viewer.