source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/toc.xsl@ 8150908

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 8150908 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1<?xml version="1.0" encoding="ASCII"?>
2<!--This file was created automatically by html2xhtml-->
3<!--from the HTML stylesheets.-->
4<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
5
6<!-- ********************************************************************
7 $Id$
8 ********************************************************************
9
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
13
14 ******************************************************************** -->
15
16<!-- ==================================================================== -->
17
18<xsl:template match="toc">
19 <xsl:choose>
20 <xsl:when test="*">
21 <xsl:if test="$process.source.toc != 0">
22 <!-- if the toc isn't empty, process it -->
23 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
24 <xsl:apply-templates/>
25 </xsl:element>
26 </xsl:if>
27 </xsl:when>
28 <xsl:otherwise>
29 <xsl:if test="$process.empty.source.toc != 0">
30 <xsl:choose>
31 <xsl:when test="parent::section or parent::sect1 or parent::sect2 or parent::sect3 or parent::sect4 or parent::sect5">
32 <xsl:apply-templates select="parent::*" mode="toc.for.section"/>
33 </xsl:when>
34 <xsl:when test="parent::article">
35 <xsl:apply-templates select="parent::*" mode="toc.for.component"/>
36 </xsl:when>
37 <xsl:when test="parent::book or parent::part">
38 <xsl:apply-templates select="parent::*" mode="toc.for.division"/>
39 </xsl:when>
40 <xsl:when test="parent::set">
41 <xsl:apply-templates select="parent::*" mode="toc.for.set"/>
42 </xsl:when>
43 <!-- there aren't any other contexts that allow toc -->
44 <xsl:otherwise>
45 <xsl:message>
46 <xsl:text>I don't know how to make a TOC in this context!</xsl:text>
47 </xsl:message>
48 </xsl:otherwise>
49 </xsl:choose>
50 </xsl:if>
51 </xsl:otherwise>
52 </xsl:choose>
53</xsl:template>
54
55<xsl:template match="tocpart|tocchap |toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
56 <xsl:variable name="sub-toc">
57 <xsl:if test="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
58 <xsl:choose>
59 <xsl:when test="$toc.list.type = 'dl'">
60 <dd>
61 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
62 <xsl:apply-templates select="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
63 </xsl:element>
64 </dd>
65 </xsl:when>
66 <xsl:otherwise>
67 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
68 <xsl:apply-templates select="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
69 </xsl:element>
70 </xsl:otherwise>
71 </xsl:choose>
72 </xsl:if>
73 </xsl:variable>
74
75 <xsl:apply-templates select="tocentry[position() != last()]"/>
76
77 <xsl:choose>
78 <xsl:when test="$toc.list.type = 'dl'">
79 <dt>
80 <xsl:apply-templates select="tocentry[position() = last()]"/>
81 </dt>
82 <xsl:copy-of select="$sub-toc"/>
83 </xsl:when>
84 <xsl:otherwise>
85 <li>
86 <xsl:apply-templates select="tocentry[position() = last()]"/>
87 <xsl:copy-of select="$sub-toc"/>
88 </li>
89 </xsl:otherwise>
90 </xsl:choose>
91</xsl:template>
92
93<xsl:template match="tocentry|tocfront|tocback">
94 <xsl:choose>
95 <xsl:when test="$toc.list.type = 'dl'">
96 <dt>
97 <xsl:call-template name="tocentry-content"/>
98 </dt>
99 </xsl:when>
100 <xsl:otherwise>
101 <li>
102 <xsl:call-template name="tocentry-content"/>
103 </li>
104 </xsl:otherwise>
105 </xsl:choose>
106</xsl:template>
107
108<xsl:template match="tocentry[position() = last()]" priority="2">
109 <xsl:call-template name="tocentry-content"/>
110</xsl:template>
111
112<xsl:template name="tocentry-content">
113 <xsl:variable name="targets" select="key('id',@linkend)"/>
114 <xsl:variable name="target" select="$targets[1]"/>
115
116 <xsl:choose>
117 <xsl:when test="@linkend">
118 <xsl:call-template name="check.id.unique">
119 <xsl:with-param name="linkend" select="@linkend"/>
120 </xsl:call-template>
121 <a>
122 <xsl:attribute name="href">
123 <xsl:call-template name="href.target">
124 <xsl:with-param name="object" select="$target"/>
125 </xsl:call-template>
126 </xsl:attribute>
127 <xsl:apply-templates/>
128 </a>
129 </xsl:when>
130 <xsl:otherwise>
131 <xsl:apply-templates/>
132 </xsl:otherwise>
133 </xsl:choose>
134</xsl:template>
135
136<!-- ==================================================================== -->
137
138<xsl:template match="*" mode="toc.for.section">
139 <xsl:call-template name="section.toc"/>
140</xsl:template>
141
142<xsl:template match="*" mode="toc.for.component">
143 <xsl:call-template name="component.toc"/>
144</xsl:template>
145
146<xsl:template match="*" mode="toc.for.section">
147 <xsl:call-template name="section.toc"/>
148</xsl:template>
149
150<xsl:template match="*" mode="toc.for.division">
151 <xsl:call-template name="division.toc"/>
152</xsl:template>
153
154<xsl:template match="*" mode="toc.for.set">
155 <xsl:call-template name="set.toc"/>
156</xsl:template>
157
158<!-- ==================================================================== -->
159
160<xsl:template match="lot|lotentry">
161</xsl:template>
162
163</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.