Documentation Tools


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

Split into smaller files.

File:
1 edited

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