Documentation Tools


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

Split into smaller files.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.