Changeset 8063

Show
Ignore:
Timestamp:
04/16/07 13:33:39 (1 year ago)
Author:
manuel
Message:

Rewritted TOC templates.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/new-xsl/xhtml/lfs-toc.xsl

    r8027 r8063  
    6666 
    6767    <!-- toc.line: 
    68            Adding the h* tags and dropping redundats links. 
     68           Adding the h* tags and dropping unneded links. 
    6969           This template is a full re-made version of the original one. --> 
    7070    <!-- The original template is in {docbook-xsl}/xhtml/autotoc.xsl --> 
    7171  <xsl:template name="toc.line"> 
    7272    <xsl:param name="toc-context" select="."/> 
    73     <xsl:param name="depth" select="1"/> 
    74     <xsl:param name="depth.from.context" select="8"/> 
    7573    <xsl:choose> 
    76         <!-- For sect1 targets, create a link --> 
     74        <!-- For non dummy sect1 targets, create a link. --> 
    7775      <xsl:when test="local-name(.) = 'sect1'"> 
    78         <a> 
    79           <xsl:attribute name="href"> 
    80             <xsl:call-template name="href.target"> 
    81               <xsl:with-param name="context" select="$toc-context"/> 
    82             </xsl:call-template> 
    83           </xsl:attribute> 
    84           <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
    85         </a> 
     76        <xsl:choose> 
     77          <xsl:when test="@role='dummy'"> 
     78            <span class="dummy"> 
     79              <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
     80            </span> 
     81          </xsl:when> 
     82          <xsl:otherwise> 
     83            <a> 
     84              <xsl:attribute name="href"> 
     85                <xsl:call-template name="href.target"> 
     86                  <xsl:with-param name="context" select="$toc-context"/> 
     87                </xsl:call-template> 
     88              </xsl:attribute> 
     89              <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
     90            </a> 
     91          </xsl:otherwise> 
     92        </xsl:choose> 
    8693      </xsl:when> 
    87         <!-- For appendix target, create a link and add the label --> 
     94        <!-- For part, preface, and chapter, use hX and add the label. 
     95             For BLFS, make it a link. --> 
     96      <xsl:when test="local-name(.) = 'part' or local-name(.) = 'preface' 
     97                      or local-name(.) = 'chapter'"> 
     98        <xsl:choose> 
     99          <xsl:when test="$book-type = 'blfs'"> 
     100            <xsl:apply-templates select="." mode="add.hX"> 
     101              <xsl:with-param name="toc-context" select="$toc-context"/> 
     102              <xsl:with-param name="with-link" select="1"/> 
     103            </xsl:apply-templates> 
     104          </xsl:when> 
     105          <xsl:otherwise> 
     106            <xsl:apply-templates select="." mode="add.hX"> 
     107              <xsl:with-param name="toc-context" select="$toc-context"/> 
     108              <xsl:with-param name="with-link" select="0"/> 
     109            </xsl:apply-templates> 
     110          </xsl:otherwise> 
     111        </xsl:choose> 
     112      </xsl:when> 
     113        <!-- For appendix , create a link and add the label. 
     114             For BLFS, use hX. --> 
    88115      <xsl:when test="local-name(.) = 'appendix'"> 
    89         <a> 
    90           <xsl:attribute name="href"> 
    91             <xsl:call-template name="href.target"> 
    92               <xsl:with-param name="context" select="$toc-context"/> 
    93             </xsl:call-template> 
    94           </xsl:attribute> 
    95           <xsl:variable name="label"> 
    96             <xsl:apply-templates select="." mode="label.markup"/> 
    97           </xsl:variable> 
    98           <xsl:copy-of select="$label"/> 
    99           <xsl:if test="$label != ''"> 
    100             <xsl:value-of select="$autotoc.label.separator"/> 
    101           </xsl:if> 
    102           <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
    103         </a> 
     116        <xsl:choose> 
     117          <xsl:when test="$book-type = 'blfs'"> 
     118            <xsl:apply-templates select="." mode="add.hX"> 
     119              <xsl:with-param name="toc-context" select="$toc-context"/> 
     120              <xsl:with-param name="with-link" select="1"/> 
     121            </xsl:apply-templates> 
     122          </xsl:when> 
     123          <xsl:otherwise> 
     124            <xsl:apply-templates select="." mode="add.link"> 
     125              <xsl:with-param name="toc-context" select="$toc-context"/> 
     126            </xsl:apply-templates> 
     127          </xsl:otherwise> 
     128        </xsl:choose> 
    104129      </xsl:when> 
    105         <!-- For chapter and preface, use h4 and add the label --> 
    106       <xsl:when test="local-name(.) = 'chapter' or local-name(.) = 'preface'"> 
    107         <h4> 
    108           <xsl:variable name="label"> 
    109             <xsl:apply-templates select="." mode="label.markup"/> 
    110           </xsl:variable> 
    111           <xsl:copy-of select="$label"/> 
    112           <xsl:if test="$label != ''"> 
    113             <xsl:value-of select="$autotoc.label.separator"/> 
    114           </xsl:if> 
    115           <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
    116         </h4> 
    117       </xsl:when> 
    118         <!-- for part, use h3 and add the label --> 
    119       <xsl:when test="local-name(.) = 'part'"> 
    120         <h3> 
    121           <xsl:variable name="label"> 
    122             <xsl:apply-templates select="." mode="label.markup"/> 
    123           </xsl:variable> 
    124           <xsl:copy-of select="$label"/> 
    125           <xsl:if test="$label != ''"> 
    126             <xsl:value-of select="$autotoc.label.separator"/> 
    127           </xsl:if> 
    128           <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
    129         </h3> 
    130       </xsl:when> 
    131         <!-- For other targets like Index, create a link inside h3 plus label it --> 
     130        <!-- For other targets like Index, use hX, create a link, and label it. --> 
    132131      <xsl:otherwise> 
    133         <h3> 
    134             <a> 
    135             <xsl:attribute name="href"> 
    136               <xsl:call-template name="href.target"> 
    137                 <xsl:with-param name="context" select="$toc-context"/> 
    138               </xsl:call-template> 
    139             </xsl:attribute> 
    140             <xsl:variable name="label"> 
    141               <xsl:apply-templates select="." mode="label.markup"/> 
    142             </xsl:variable> 
    143             <xsl:copy-of select="$label"/> 
    144             <xsl:if test="$label != ''"> 
    145               <xsl:value-of select="$autotoc.label.separator"/> 
    146             </xsl:if> 
    147             <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
    148           </a> 
    149         </h3> 
     132        <xsl:apply-templates select="." mode="add.hX"> 
     133          <xsl:with-param name="toc-context" select="$toc-context"/> 
     134          <xsl:with-param name="with-link" select="1"/> 
     135        </xsl:apply-templates> 
    150136      </xsl:otherwise> 
    151137    </xsl:choose> 
    152138  </xsl:template> 
    153139 
     140    <!-- Self-made template to add hX tags to toc lines. --> 
     141  <xsl:template match="*" mode="add.hX"> 
     142    <xsl:param name="toc-context" select="."/> 
     143    <xsl:param name="with-link" select="0"/> 
     144    <xsl:param name="hlevel"> 
     145      <xsl:choose> 
     146        <xsl:when test="local-name(.)='chapter' or local-name(.)='preface'">4</xsl:when> 
     147        <xsl:otherwise>3</xsl:otherwise> 
     148      </xsl:choose> 
     149    </xsl:param> 
     150    <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml"> 
     151      <xsl:choose> 
     152        <xsl:when test="$with-link != 0"> 
     153          <xsl:apply-templates select="." mode="add.link"> 
     154            <xsl:with-param name="toc-context" select="$toc-context"/> 
     155          </xsl:apply-templates> 
     156        </xsl:when> 
     157        <xsl:otherwise> 
     158          <xsl:apply-templates select="." mode="label.and.title"/> 
     159        </xsl:otherwise> 
     160      </xsl:choose> 
     161    </xsl:element> 
     162  </xsl:template> 
     163 
     164    <!-- Self-made template to made toc line a link. --> 
     165  <xsl:template match="*" mode="add.link"> 
     166    <xsl:param name="toc-context" select="."/> 
     167    <a> 
     168      <xsl:attribute name="href"> 
     169        <xsl:call-template name="href.target"> 
     170          <xsl:with-param name="context" select="$toc-context"/> 
     171        </xsl:call-template> 
     172      </xsl:attribute> 
     173      <xsl:apply-templates select="." mode="label.and.title"/> 
     174    </a> 
     175  </xsl:template> 
     176 
     177    <!-- Self-made template to write the target title and label it. --> 
     178  <xsl:template match="*" mode="label.and.title"> 
     179    <xsl:variable name="label"> 
     180      <xsl:apply-templates select="." mode="label.markup"/> 
     181    </xsl:variable> 
     182    <xsl:copy-of select="$label"/> 
     183    <xsl:if test="$label != ''"> 
     184      <xsl:value-of select="$autotoc.label.separator"/> 
     185    </xsl:if> 
     186    <xsl:apply-templates select="." mode="titleabbrev.markup"/> 
     187  </xsl:template> 
     188 
    154189</xsl:stylesheet>