1 | <?xml version="1.0"?> |
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
---|
3 | <xsl:output method="html" version="4.01" encoding="ISO-8859-1"/> |
---|
4 | <!-- |
---|
5 | - returns the filename associated to an ID in the original file |
---|
6 | --> |
---|
7 | <xsl:template name="filename"> |
---|
8 | <xsl:param name="name" select="string(@href)"/> |
---|
9 | <xsl:choose> |
---|
10 | <xsl:when test="$name = '#Introducti'"> |
---|
11 | <xsl:text>intro.html</xsl:text> |
---|
12 | </xsl:when> |
---|
13 | <xsl:when test="$name = '#Documentat'"> |
---|
14 | <xsl:text>docs.html</xsl:text> |
---|
15 | </xsl:when> |
---|
16 | <xsl:when test="$name = '#Reporting'"> |
---|
17 | <xsl:text>bugs.html</xsl:text> |
---|
18 | </xsl:when> |
---|
19 | <xsl:when test="$name = '#help'"> |
---|
20 | <xsl:text>help.html</xsl:text> |
---|
21 | </xsl:when> |
---|
22 | <xsl:when test="$name = '#Help'"> |
---|
23 | <xsl:text>help.html</xsl:text> |
---|
24 | </xsl:when> |
---|
25 | <xsl:when test="$name = '#Downloads'"> |
---|
26 | <xsl:text>downloads.html</xsl:text> |
---|
27 | </xsl:when> |
---|
28 | <xsl:when test="$name = '#News'"> |
---|
29 | <xsl:text>news.html</xsl:text> |
---|
30 | </xsl:when> |
---|
31 | <xsl:when test="$name = '#Contributi'"> |
---|
32 | <xsl:text>contribs.html</xsl:text> |
---|
33 | </xsl:when> |
---|
34 | <xsl:when test="$name = '#xsltproc'"> |
---|
35 | <xsl:text>xsltproc2.html</xsl:text> |
---|
36 | </xsl:when> |
---|
37 | <xsl:when test="$name = '#API'"> |
---|
38 | <xsl:text>API.html</xsl:text> |
---|
39 | </xsl:when> |
---|
40 | <xsl:when test="$name = '#Extensions'"> |
---|
41 | <xsl:text>extensions.html</xsl:text> |
---|
42 | </xsl:when> |
---|
43 | <xsl:when test="$name = '#Internals'"> |
---|
44 | <xsl:text>internals.html</xsl:text> |
---|
45 | </xsl:when> |
---|
46 | <xsl:when test="$name = '#DocBook'"> |
---|
47 | <xsl:text>docbook.html</xsl:text> |
---|
48 | </xsl:when> |
---|
49 | <xsl:when test="$name = '#FAQ'"> |
---|
50 | <xsl:text>FAQ.html</xsl:text> |
---|
51 | </xsl:when> |
---|
52 | <xsl:when test="$name = '#Python'"> |
---|
53 | <xsl:text>python.html</xsl:text> |
---|
54 | </xsl:when> |
---|
55 | <xsl:when test="$name = ''"> |
---|
56 | <xsl:text>unknown.html</xsl:text> |
---|
57 | </xsl:when> |
---|
58 | <xsl:otherwise> |
---|
59 | <xsl:value-of select="$name"/> |
---|
60 | </xsl:otherwise> |
---|
61 | </xsl:choose> |
---|
62 | </xsl:template> |
---|
63 | <!-- |
---|
64 | - The table of content |
---|
65 | --> |
---|
66 | <xsl:variable name="toc"> |
---|
67 | <form action="search.php" |
---|
68 | enctype="application/x-www-form-urlencoded" method="GET"> |
---|
69 | <input name="query" type="TEXT" size="20" value=""/> |
---|
70 | <input name="submit" type="submit" value="Search ..."/> |
---|
71 | </form> |
---|
72 | <ul> |
---|
73 | <li><a href="index.html">Home</a></li> |
---|
74 | <xsl:for-each select="/html/body/h2"> |
---|
75 | <xsl:variable name="filename"> |
---|
76 | <xsl:call-template name="filename"> |
---|
77 | <xsl:with-param name="name" select="concat('#', string(a[1]/@name))"/> |
---|
78 | </xsl:call-template> |
---|
79 | </xsl:variable> |
---|
80 | <li> |
---|
81 | <xsl:element name="a"> |
---|
82 | <xsl:attribute name="href"> |
---|
83 | <xsl:value-of select="$filename"/> |
---|
84 | </xsl:attribute> |
---|
85 | <xsl:value-of select="."/> |
---|
86 | </xsl:element> |
---|
87 | </li> |
---|
88 | </xsl:for-each> |
---|
89 | <li><a href="xslt.html">flat page</a>, <a href="site.xsl">stylesheet</a></li> |
---|
90 | </ul> |
---|
91 | </xsl:variable> |
---|
92 | <xsl:variable name="api"> |
---|
93 | <ul> |
---|
94 | <li><a href="APIchunk0.html">Alphabetic</a></li> |
---|
95 | <li><a href="APIconstructors.html">Constructors</a></li> |
---|
96 | <li><a href="APIfunctions.html">Functions/Types</a></li> |
---|
97 | <li><a href="APIfiles.html">Modules</a></li> |
---|
98 | <li><a href="APIsymbols.html">Symbols</a></li> |
---|
99 | </ul> |
---|
100 | </xsl:variable> |
---|
101 | <xsl:variable name="related"> |
---|
102 | <ul> |
---|
103 | <li><a href="tutorial/libxslttutorial.html">Tutorial</a></li> |
---|
104 | <li><a href="xsltproc.html">Man page for xsltproc</a></li> |
---|
105 | <li><a href="http://mail.gnome.org/archives/xslt/">Mail archive</a></li> |
---|
106 | <li><a href="http://xmlsoft.org/">XML libxml</a></li> |
---|
107 | <li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li> |
---|
108 | <li><a href="ftp://xmlsoft.org/">FTP</a></li> |
---|
109 | <li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li> |
---|
110 | <li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li> |
---|
111 | <li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li> |
---|
112 | <li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li> |
---|
113 | <li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxslt">Bug Tracker</a></li> |
---|
114 | <li><a href="http://xsldbg.sourceforge.net/">Xsldbg Debugger</a></li> |
---|
115 | </ul> |
---|
116 | </xsl:variable> |
---|
117 | <xsl:template name="toc"> |
---|
118 | <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"> |
---|
119 | <tr> |
---|
120 | <td> |
---|
121 | <table width="100%" border="0" cellspacing="1" cellpadding="3"> |
---|
122 | <tr> |
---|
123 | <td colspan="1" bgcolor="#eecfa1" align="center"> |
---|
124 | <center> |
---|
125 | <b>Main Menu</b> |
---|
126 | </center> |
---|
127 | </td> |
---|
128 | </tr> |
---|
129 | <tr> |
---|
130 | <td bgcolor="#fffacd"> |
---|
131 | <xsl:copy-of select="$toc"/> |
---|
132 | </td> |
---|
133 | </tr> |
---|
134 | </table> |
---|
135 | <table width="100%" border="0" cellspacing="1" cellpadding="3"> |
---|
136 | <tr> |
---|
137 | <td colspan="1" bgcolor="#eecfa1" align="center"> |
---|
138 | <center> |
---|
139 | <b>Related links</b> |
---|
140 | </center> |
---|
141 | </td> |
---|
142 | </tr> |
---|
143 | <tr> |
---|
144 | <td bgcolor="#fffacd"> |
---|
145 | <xsl:copy-of select="$related"/> |
---|
146 | </td> |
---|
147 | </tr> |
---|
148 | </table> |
---|
149 | <table width="100%" border="0" cellspacing="1" cellpadding="3"> |
---|
150 | <tr> |
---|
151 | <td colspan="1" bgcolor="#eecfa1" align="center"> |
---|
152 | <center> |
---|
153 | <b>API Indexes</b> |
---|
154 | </center> |
---|
155 | </td> |
---|
156 | </tr> |
---|
157 | <tr> |
---|
158 | <td bgcolor="#fffacd"> |
---|
159 | <xsl:copy-of select="$api"/> |
---|
160 | </td> |
---|
161 | </tr> |
---|
162 | </table> |
---|
163 | </td> |
---|
164 | </tr> |
---|
165 | </table> |
---|
166 | </xsl:template> |
---|
167 | <xsl:template mode="head" match="title"> |
---|
168 | <title> |
---|
169 | <xsl:apply-templates/> |
---|
170 | </title> |
---|
171 | </xsl:template> |
---|
172 | <xsl:template mode="head" match="meta"> |
---|
173 | </xsl:template> |
---|
174 | <!-- |
---|
175 | - The global title |
---|
176 | --> |
---|
177 | <xsl:variable name="globaltitle" select="string(/html/body/h1[1])"/> |
---|
178 | <!-- |
---|
179 | - Write the styles in the head |
---|
180 | --> |
---|
181 | <xsl:template name="style"> |
---|
182 | <style type="text/css"><xsl:text disable-output-escaping="yes"><!--</xsl:text> |
---|
183 | TD {font-family: Verdana,Arial,Helvetica} |
---|
184 | BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em} |
---|
185 | H1 {font-family: Verdana,Arial,Helvetica} |
---|
186 | H2 {font-family: Verdana,Arial,Helvetica} |
---|
187 | H3 {font-family: Verdana,Arial,Helvetica} |
---|
188 | A:link, A:visited, A:active { text-decoration: underline } |
---|
189 | <xsl:text disable-output-escaping="yes">--></xsl:text></style> |
---|
190 | </xsl:template> |
---|
191 | <!-- |
---|
192 | - Write the title box on top |
---|
193 | --> |
---|
194 | <xsl:template name="titlebox"> |
---|
195 | <xsl:param name="title" select="'Main Page'"/> |
---|
196 | <table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"> |
---|
197 | <tr> |
---|
198 | <td width="100"> |
---|
199 | <a href="http://www.gnome.org/"><img src="gnome2.png" alt="Gnome2 Logo"/></a> |
---|
200 | <a href="http://www.redhat.com"><img src="redhat.gif" alt="Red Hat Logo"/></a> |
---|
201 | <div align="left"> |
---|
202 | <a href="http://xmlsoft.org/XSLT/"><img src="Libxslt-Logo-180x168.gif" alt="Made with Libxslt Logo"/></a> |
---|
203 | </div> |
---|
204 | </td> |
---|
205 | <td> |
---|
206 | <table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"> |
---|
207 | <tr> |
---|
208 | <td> |
---|
209 | <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"> |
---|
210 | <tr> |
---|
211 | <td align="center"> |
---|
212 | <xsl:element name="h1"> |
---|
213 | <xsl:value-of select="$globaltitle"/> |
---|
214 | </xsl:element> |
---|
215 | <xsl:element name="h2"> |
---|
216 | <xsl:value-of select="$title"/> |
---|
217 | </xsl:element> |
---|
218 | </td> |
---|
219 | </tr> |
---|
220 | </table> |
---|
221 | </td> |
---|
222 | </tr> |
---|
223 | </table> |
---|
224 | </td> |
---|
225 | </tr> |
---|
226 | </table> |
---|
227 | </xsl:template> |
---|
228 | <!-- |
---|
229 | - Handling of nodes in the body before the first H2, table of content |
---|
230 | - Everything is just copied over, except href which may get rewritten |
---|
231 | - and h1/h2/a at the top level |
---|
232 | --> |
---|
233 | <xsl:template priority="2" mode="subcontent" match="a"> |
---|
234 | <xsl:variable name="filename"> |
---|
235 | <xsl:call-template name="filename"> |
---|
236 | <xsl:with-param name="name" select="string(@href)"/> |
---|
237 | </xsl:call-template> |
---|
238 | </xsl:variable> |
---|
239 | <xsl:copy> |
---|
240 | <xsl:attribute name="href"> |
---|
241 | <xsl:value-of select="$filename"/> |
---|
242 | </xsl:attribute> |
---|
243 | <xsl:apply-templates mode="subcontent" select="node()"/> |
---|
244 | </xsl:copy> |
---|
245 | </xsl:template> |
---|
246 | <xsl:template mode="subcontent" match="@*|node()"> |
---|
247 | <xsl:copy> |
---|
248 | <xsl:apply-templates mode="subcontent" select="@*|node()"/> |
---|
249 | </xsl:copy> |
---|
250 | </xsl:template> |
---|
251 | <xsl:template mode="content" match="@*|node()"> |
---|
252 | <xsl:if test="name() != 'h1' and name() != 'h2'"> |
---|
253 | <xsl:copy> |
---|
254 | <xsl:apply-templates mode="subcontent" select="@*|node()"/> |
---|
255 | </xsl:copy> |
---|
256 | </xsl:if> |
---|
257 | </xsl:template> |
---|
258 | <!-- |
---|
259 | - Handling of nodes in the body after an H2 |
---|
260 | - Open a new file and dump all the siblings up to the next H2 |
---|
261 | --> |
---|
262 | <xsl:template name="subfile"> |
---|
263 | <xsl:param name="header" select="following-sibling::h2[1]"/> |
---|
264 | <xsl:variable name="filename"> |
---|
265 | <xsl:call-template name="filename"> |
---|
266 | <xsl:with-param name="name" select="concat('#', string($header/a[1]/@name))"/> |
---|
267 | </xsl:call-template> |
---|
268 | </xsl:variable> |
---|
269 | <xsl:variable name="title"> |
---|
270 | <xsl:value-of select="$header"/> |
---|
271 | </xsl:variable> |
---|
272 | <xsl:document href="{$filename}" method="html" version="4.01" encoding="ISO-8859-1"> |
---|
273 | <html> |
---|
274 | <head> |
---|
275 | <xsl:call-template name="style"/> |
---|
276 | <xsl:element name="title"> |
---|
277 | <xsl:value-of select="$title"/> |
---|
278 | </xsl:element> |
---|
279 | </head> |
---|
280 | <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"> |
---|
281 | <xsl:call-template name="titlebox"> |
---|
282 | <xsl:with-param name="title" select="$title"/> |
---|
283 | </xsl:call-template> |
---|
284 | <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"> |
---|
285 | <tr> |
---|
286 | <td bgcolor="#8b7765"> |
---|
287 | <table border="0" cellspacing="0" cellpadding="2" width="100%"> |
---|
288 | <tr> |
---|
289 | <td valign="top" width="200" bgcolor="#8b7765"> |
---|
290 | <xsl:call-template name="toc"/> |
---|
291 | </td> |
---|
292 | <td valign="top" bgcolor="#8b7765"> |
---|
293 | <table border="0" cellspacing="0" cellpadding="1" width="100%"> |
---|
294 | <tr> |
---|
295 | <td> |
---|
296 | <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"> |
---|
297 | <tr> |
---|
298 | <td> |
---|
299 | <table border="0" cellpadding="3" cellspacing="1" width="100%"> |
---|
300 | <tr> |
---|
301 | <td bgcolor="#fffacd"> |
---|
302 | <xsl:apply-templates mode="subfile" select="$header/following-sibling::*[preceding-sibling::h2[1] = $header and name() != 'h2' ]"/> |
---|
303 | <p><a href="bugs.html">Daniel Veillard</a></p> |
---|
304 | </td> |
---|
305 | </tr> |
---|
306 | </table> |
---|
307 | </td> |
---|
308 | </tr> |
---|
309 | </table> |
---|
310 | </td> |
---|
311 | </tr> |
---|
312 | </table> |
---|
313 | </td> |
---|
314 | </tr> |
---|
315 | </table> |
---|
316 | </td> |
---|
317 | </tr> |
---|
318 | </table> |
---|
319 | </body> |
---|
320 | </html> |
---|
321 | </xsl:document> |
---|
322 | </xsl:template> |
---|
323 | <xsl:template mode="subfile" match="@*|node()"> |
---|
324 | <xsl:copy> |
---|
325 | <xsl:apply-templates mode="content" select="@*|node()"/> |
---|
326 | </xsl:copy> |
---|
327 | </xsl:template> |
---|
328 | <!-- |
---|
329 | - Handling of the initial body and head HTML document |
---|
330 | --> |
---|
331 | <xsl:template match="body"> |
---|
332 | <xsl:variable name="firsth2" select="./h2[1]"/> |
---|
333 | <xsl:variable name="rest2" select="./h2[position()>1]"/> |
---|
334 | <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000"> |
---|
335 | <xsl:call-template name="titlebox"> |
---|
336 | <xsl:with-param name="title" select="'libxslt'"/> |
---|
337 | </xsl:call-template> |
---|
338 | <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"> |
---|
339 | <tr> |
---|
340 | <td bgcolor="#8b7765"> |
---|
341 | <table border="0" cellspacing="0" cellpadding="2" width="100%"> |
---|
342 | <tr> |
---|
343 | <td valign="top" width="200" bgcolor="#8b7765"> |
---|
344 | <xsl:call-template name="toc"/> |
---|
345 | </td> |
---|
346 | <td valign="top" bgcolor="#8b7765"> |
---|
347 | <table border="0" cellspacing="0" cellpadding="1" width="100%"> |
---|
348 | <tr> |
---|
349 | <td> |
---|
350 | <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"> |
---|
351 | <tr> |
---|
352 | <td> |
---|
353 | <table border="0" cellpadding="3" cellspacing="1" width="100%"> |
---|
354 | <tr> |
---|
355 | <td bgcolor="#fffacd"> |
---|
356 | <xsl:apply-templates mode="content" select="($firsth2/preceding-sibling::*)"/> |
---|
357 | <xsl:for-each select="./h2"> |
---|
358 | <xsl:call-template name="subfile"> |
---|
359 | <xsl:with-param name="header" select="."/> |
---|
360 | </xsl:call-template> |
---|
361 | </xsl:for-each> |
---|
362 | <p><a href="bugs.html">Daniel Veillard</a></p> |
---|
363 | </td> |
---|
364 | </tr> |
---|
365 | </table> |
---|
366 | </td> |
---|
367 | </tr> |
---|
368 | </table> |
---|
369 | </td> |
---|
370 | </tr> |
---|
371 | </table> |
---|
372 | </td> |
---|
373 | </tr> |
---|
374 | </table> |
---|
375 | </td> |
---|
376 | </tr> |
---|
377 | </table> |
---|
378 | </body> |
---|
379 | </xsl:template> |
---|
380 | <xsl:template match="head"> |
---|
381 | <head> |
---|
382 | <xsl:call-template name="style"/> |
---|
383 | <xsl:apply-templates mode="head"/> |
---|
384 | </head> |
---|
385 | </xsl:template> |
---|
386 | <xsl:template match="html"> |
---|
387 | <html> |
---|
388 | <xsl:apply-templates/> |
---|
389 | </html> |
---|
390 | </xsl:template> |
---|
391 | </xsl:stylesheet> |
---|