source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/website/autolayout.xsl@ c158fe6

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since c158fe6 was b1a51ac1, checked in by Krejzi <krejzi@…>, 11 years ago

Import new branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10389 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 6.8 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version="1.0">
4
5<xsl:output method="xml" indent="no"
6 doctype-public="-//Norman Walsh//DTD Website Autolayout V2.5.0//EN"
7 doctype-system="http://docbook.sourceforge.net/release/website/2.5.0/schema/dtd/autolayout.dtd"
8/>
9
10<xsl:strip-space elements="toc tocentry layout copyright"/>
11
12<xsl:template match="layout">
13 <autolayout>
14 <xsl:text>&#10;</xsl:text>
15 <xsl:apply-templates/>
16 </autolayout>
17 <xsl:text>&#10;</xsl:text>
18</xsl:template>
19
20<xsl:template match="style|script|headlink|copyright|config">
21 <xsl:apply-templates select="." mode="copy"/>
22</xsl:template>
23
24<xsl:template match="*" mode="copy">
25 <xsl:element name="{name(.)}">
26 <xsl:copy-of select="@*"/>
27 <xsl:apply-templates mode="copy"/>
28 </xsl:element>
29</xsl:template>
30
31<xsl:template match="toc">
32 <xsl:if test="not(@page)">
33 <xsl:message terminate="yes">
34 <xsl:text>All toc entries must have a page attribute.</xsl:text>
35 </xsl:message>
36 </xsl:if>
37
38 <xsl:variable name="page" select="document(@page,.)"/>
39
40 <toc>
41 <xsl:call-template name="tocentry"/>
42 </toc>
43 <xsl:text>&#10;</xsl:text>
44</xsl:template>
45
46<xsl:template match="tocentry">
47 <tocentry>
48 <xsl:call-template name="tocentry"/>
49 </tocentry>
50 <xsl:text>&#10;</xsl:text>
51</xsl:template>
52
53<xsl:template match="notoc">
54 <notoc>
55 <xsl:call-template name="tocentry"/>
56 </notoc>
57 <xsl:text>&#10;</xsl:text>
58</xsl:template>
59
60<xsl:template name="tocentry">
61 <xsl:if test="@revisionflag">
62 <xsl:attribute name="revisionflag">
63 <xsl:value-of select="@revisionflag"/>
64 </xsl:attribute>
65 </xsl:if>
66 <xsl:choose>
67 <xsl:when test="@href">
68 <xsl:call-template name="tocentry.href"/>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:call-template name="tocentry.page"/>
72 </xsl:otherwise>
73 </xsl:choose>
74</xsl:template>
75
76<xsl:template name="tocentry.href">
77 <xsl:if test="not(@href)">
78 <xsl:message terminate="yes">
79 <xsl:text>All toc entries must have an href attribute.</xsl:text>
80 </xsl:message>
81 </xsl:if>
82
83 <xsl:if test="not(@id)">
84 <xsl:message terminate="yes">
85 <xsl:text>All href toc entries must have an id attribute.</xsl:text>
86 </xsl:message>
87 </xsl:if>
88
89 <xsl:message>
90 <xsl:text>off site: </xsl:text>
91 <xsl:value-of select="@href"/>
92 </xsl:message>
93
94 <xsl:attribute name="id">
95 <xsl:value-of select="@id"/>
96 </xsl:attribute>
97 <xsl:attribute name="href">
98 <xsl:value-of select="@href"/>
99 </xsl:attribute>
100 <xsl:if test="@tocskip = '1'">
101 <xsl:attribute name="tocskip">
102 <xsl:value-of select="@tocskip"/>
103 </xsl:attribute>
104 </xsl:if>
105
106 <xsl:if test="not(title)">
107 <xsl:message terminate="yes">
108 <xsl:text>Off-site links must provide a title.</xsl:text>
109 </xsl:message>
110 </xsl:if>
111
112 <xsl:text>&#10;</xsl:text>
113 <xsl:apply-templates select="title|titleabbrev|summary" mode="copy"/>
114 <xsl:text>&#10;</xsl:text>
115 <xsl:apply-templates select="tocentry"/>
116</xsl:template>
117
118<xsl:template name="tocentry.page">
119 <xsl:if test="not(@page)">
120 <xsl:message terminate="yes">
121 <xsl:text>All toc entries must have a page attribute.</xsl:text>
122 </xsl:message>
123 </xsl:if>
124
125 <xsl:variable name="page" select="document(@page,.)"/>
126
127 <xsl:if test="not($page/*[1]/@id)">
128 <xsl:message terminate="yes">
129 <xsl:value-of select="@page"/>
130 <xsl:text>: missing ID.</xsl:text>
131 </xsl:message>
132 </xsl:if>
133
134 <xsl:variable name="id" select="$page/*[1]/@id"/>
135
136 <xsl:variable name="filename">
137 <xsl:choose>
138 <xsl:when test="@filename">
139 <xsl:value-of select="@filename"/>
140 </xsl:when>
141 <xsl:when test="/layout/config[@param='default-filename']">
142 <xsl:value-of select="(/layout/config[@param='default-filename'])[1]/@value"/>
143 </xsl:when>
144 <xsl:otherwise>index.html</xsl:otherwise>
145 </xsl:choose>
146 </xsl:variable>
147
148 <xsl:variable name="dir">
149 <xsl:apply-templates select="." mode="calculate-dir"/>
150 </xsl:variable>
151
152 <xsl:if test="$filename = ''">
153 <xsl:message terminate="yes">
154 <xsl:value-of select="@page"/>
155 <xsl:text>: missing filename.</xsl:text>
156 </xsl:message>
157 </xsl:if>
158
159 <xsl:message>
160 <xsl:value-of select="@page"/>
161 <xsl:text>: </xsl:text>
162 <xsl:if test="$dir != ''">
163 <xsl:value-of select="$dir"/>
164 </xsl:if>
165 <xsl:value-of select="$filename"/>
166 </xsl:message>
167
168 <xsl:attribute name="page">
169 <xsl:value-of select="@page"/>
170 </xsl:attribute>
171 <xsl:attribute name="id">
172 <xsl:value-of select="$id"/>
173 </xsl:attribute>
174 <xsl:if test="$dir != ''">
175 <xsl:attribute name="dir">
176 <xsl:value-of select="$dir"/>
177 </xsl:attribute>
178 </xsl:if>
179 <xsl:attribute name="filename">
180 <xsl:value-of select="$filename"/>
181 </xsl:attribute>
182 <xsl:if test="@tocskip = '1'">
183 <xsl:attribute name="tocskip">
184 <xsl:value-of select="@tocskip"/>
185 </xsl:attribute>
186 </xsl:if>
187
188 <xsl:text>&#10;</xsl:text>
189 <xsl:choose>
190 <xsl:when test="title">
191 <xsl:apply-templates select="title" mode="copy"/>
192 </xsl:when>
193 <xsl:otherwise>
194 <title>
195 <xsl:apply-templates select="$page/*[1]/head/title"/>
196 </title>
197 </xsl:otherwise>
198 </xsl:choose>
199 <xsl:text>&#10;</xsl:text>
200
201 <xsl:if test="titleabbrev or $page/*[1]/head/titleabbrev">
202 <xsl:choose>
203 <xsl:when test="titleabbrev">
204 <xsl:apply-templates select="titleabbrev" mode="copy"/>
205 </xsl:when>
206 <xsl:otherwise>
207 <titleabbrev>
208 <xsl:apply-templates select="$page/*[1]/head/titleabbrev"/>
209 </titleabbrev>
210 </xsl:otherwise>
211 </xsl:choose>
212 <xsl:text>&#10;</xsl:text>
213 </xsl:if>
214
215 <xsl:if test="summary or $page/*[1]/head/summary">
216 <xsl:choose>
217 <xsl:when test="summary">
218 <xsl:apply-templates select="summary" mode="copy"/>
219 </xsl:when>
220 <xsl:otherwise>
221 <summary>
222 <xsl:apply-templates select="$page/*[1]/head/summary"/>
223 </summary>
224 </xsl:otherwise>
225 </xsl:choose>
226 <xsl:text>&#10;</xsl:text>
227 </xsl:if>
228
229 <xsl:apply-templates select="tocentry"/>
230</xsl:template>
231
232<xsl:template match="*" mode="calculate-dir">
233 <xsl:choose>
234 <xsl:when test="starts-with(@dir, '/')">
235 <!-- if the directory on this begins with a "/", we're done... -->
236 <xsl:value-of select="substring-after(@dir, '/')"/>
237 <xsl:text>/</xsl:text>
238 </xsl:when>
239
240 <xsl:when test="parent::*">
241 <!-- if there's a parent, try it -->
242 <xsl:apply-templates select="parent::*" mode="calculate-dir"/>
243 <xsl:if test="@dir">
244 <xsl:value-of select="@dir"/>
245 <xsl:text>/</xsl:text>
246 </xsl:if>
247 </xsl:when>
248
249 <xsl:otherwise>
250 <xsl:if test="@dir">
251 <xsl:value-of select="@dir"/>
252 <xsl:text>/</xsl:text>
253 </xsl:if>
254 </xsl:otherwise>
255 </xsl:choose>
256</xsl:template>
257
258</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.