source: stylesheets/lfs-xsl/xhtml/lfs-titles.xsl@ 55af6ce

lazarus trunk
Last change on this file since 55af6ce was 0d7e9a26, checked in by Pierre Labastie <pierre.labastie@…>, 4 months ago

Fix output of anchors with same id in sect3

The template for sect3.titlepage generates:
<h3 class="sect3">

<a id="{id of sect3}" name="{id of sect3}"></a>
<h4 class="title">

<a id="{id of sect3}" name="{id of sect3}">i{title of sect3}</a>

</h4>

</h3>
resulting in double definition of the same id, which is a validity error
in XML documents.
Replace with the same template as for sect2, using h3 instead of h2.

  • Property mode set to 100644
File size: 6.7 KB
Line 
1<?xml version='1.0' encoding='UTF-8'?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns="http://www.w3.org/1999/xhtml"
5 version="1.0">
6
7 <!-- This stylesheet controls the h* xhtml tags used for several titles -->
8
9 <!-- preface.titlepage:
10 Uses h1 and removed a lot of unneeded code.
11 No label in preface. -->
12 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
13 <xsl:template name="preface.titlepage">
14 <h1 class="{name(.)}">
15 <xsl:if test="@id">
16 <a id="{@id}" name="{@id}"/>
17 </xsl:if>
18 <xsl:value-of select="title"/>
19 </h1>
20 </xsl:template>
21
22 <!-- part.titlepage:
23 Uses h1 and removed a lot of unneeded code.
24 When sections are not labeled, we want the part label in TOC
25 but not in titlepage. -->
26 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
27 <xsl:template name="part.titlepage">
28 <h1 class="{name(.)}">
29 <xsl:if test="@id">
30 <a id="{@id}" name="{@id}"/>
31 </xsl:if>
32 <xsl:if test="$section.autolabel != 0">
33 <xsl:apply-templates select="." mode="label.markup"/>
34 <xsl:text>. </xsl:text>
35 </xsl:if>
36 <xsl:value-of select="title"/>
37 </h1>
38 </xsl:template>
39
40 <!-- partintro.titlepage:
41 Uses h2 and removed a lot of unneeded code. -->
42 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
43 <xsl:template name="partintro.titlepage">
44 <xsl:if test="title">
45 <h2 class="{name(.)}">
46 <xsl:if test="@id">
47 <a id="{@id}" name="{@id}"/>
48 </xsl:if>
49 <xsl:value-of select="title"/>
50 </h2>
51 </xsl:if>
52 </xsl:template>
53
54 <!-- appendix.titlepage:
55 Uses h1 and removed a lot of unneeded code.
56 When sections are not labeled, we want the appendix label in TOC
57 but not in titlepage. -->
58 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
59 <xsl:template name="appendix.titlepage">
60 <h1 class="{name(.)}">
61 <xsl:if test="@id">
62 <a id="{@id}" name="{@id}"/>
63 </xsl:if>
64 <xsl:if test="$section.autolabel != 0">
65 <xsl:apply-templates select="." mode="label.markup"/>
66 <xsl:text>. </xsl:text>
67 </xsl:if>
68 <xsl:value-of select="title"/>
69 </h1>
70 </xsl:template>
71
72 <!-- chapter.titlepage:
73 Uses h1 and removed a lot of unneeded code.
74 When sections are not labeled, we want the chapter label in TOC
75 but not in titlepage. -->
76 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
77 <xsl:template name="chapter.titlepage">
78 <h1 class="{name(.)}">
79 <xsl:if test="@id">
80 <a id="{@id}" name="{@id}"/>
81 </xsl:if>
82 <xsl:if test="$section.autolabel != 0">
83 <xsl:apply-templates select="." mode="label.markup"/>
84 <xsl:text>. </xsl:text>
85 </xsl:if>
86 <xsl:value-of select="title"/>
87 </h1>
88 </xsl:template>
89
90 <!-- sect1.titlepage:
91 Uses h1 and removed a lot of unneeded code. -->
92 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
93 <xsl:template name="sect1.titlepage">
94 <h1 class="{name(.)}">
95 <xsl:if test="@id">
96 <a id="{@id}" name="{@id}"/>
97 </xsl:if>
98 <xsl:if test="$section.autolabel != 0">
99 <xsl:apply-templates select="." mode="label.markup"/>
100 <xsl:text>. </xsl:text>
101 </xsl:if>
102 <xsl:value-of select="title"/>
103 </h1>
104 </xsl:template>
105
106 <!-- sect2.titlepage:
107 Uses h2 and removed a lot of unneeded code.
108 Skip empty titles.
109 No label in preface. -->
110 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
111 <xsl:template name="sect2.titlepage">
112 <xsl:choose>
113 <xsl:when test="string-length(title) = 0"/>
114 <xsl:otherwise>
115 <h2 class="{name(.)}">
116 <xsl:if test="@id">
117 <a id="{@id}" name="{@id}"/>
118 </xsl:if>
119 <xsl:if test="not(ancestor::preface) and $section.autolabel != 0">
120 <xsl:apply-templates select="." mode="label.markup"/>
121 <xsl:text>. </xsl:text>
122 </xsl:if>
123 <xsl:value-of select="title"/>
124 </h2>
125 </xsl:otherwise>
126 </xsl:choose>
127 </xsl:template>
128
129 <!-- sect3.titlepage:
130 Same as sect2 except it uses h3 -->
131 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
132 <xsl:template name="sect3.titlepage">
133 <xsl:choose>
134 <xsl:when test="string-length(title) = 0"/>
135 <xsl:otherwise>
136 <h3 class="{name(.)}">
137 <xsl:if test="@id">
138 <a id="{@id}" name="{@id}"/>
139 </xsl:if>
140 <xsl:if test="not(ancestor::preface) and $section.autolabel != 0">
141 <xsl:apply-templates select="." mode="label.markup"/>
142 <xsl:text>. </xsl:text>
143 </xsl:if>
144 <xsl:value-of select="title"/>
145 </h3>
146 </xsl:otherwise>
147 </xsl:choose>
148 </xsl:template>
149 <!-- dedication.titlepage:
150 Uses h2 and removed a lot of unneeded code. -->
151 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
152 <xsl:template name="dedication.titlepage">
153 <h2>
154 <xsl:value-of select="title"/>
155 </h2>
156 </xsl:template>
157
158 <!-- bridgehead:
159 We use always renderas attributes and want the output h* level
160 matching the defined sect* level.
161 Create the anchor only if there is an @id. -->
162 <!-- The original template is in {docbook-xsl}/xhtml/sections.xsl -->
163 <xsl:template match="bridgehead">
164 <xsl:variable name="hlevel">
165 <xsl:choose>
166 <xsl:when test="@renderas = 'sect1'">1</xsl:when>
167 <xsl:when test="@renderas = 'sect2'">2</xsl:when>
168 <xsl:when test="@renderas = 'sect3'">3</xsl:when>
169 <xsl:when test="@renderas = 'sect4'">4</xsl:when>
170 <xsl:when test="@renderas = 'sect5'">5</xsl:when>
171 </xsl:choose>
172 </xsl:variable>
173 <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
174 <xsl:if test="@id">
175 <a id="{@id}" name="{@id}"/>
176 </xsl:if>
177 <xsl:apply-templates/>
178 </xsl:element>
179 </xsl:template>
180
181 <!-- book.titlepage.verso:
182 Process bookinfo/bibliosource from here. -->
183 <!-- The original template is in {docbook-xsl}/xhtml/titlepage.templates.xsl -->
184 <xsl:template name="book.titlepage.verso">
185 <xsl:apply-templates select="bookinfo/bibliosource"/>
186 </xsl:template>
187
188 <!-- bookinfo/bibliosource:
189 Self-made template to handle bibliosource when inside bookinfo. -->
190 <xsl:template match="bookinfo/bibliosource">
191 <p class="copyright">
192 <xsl:apply-templates/>
193 </p>
194 </xsl:template>
195
196</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.