site.xsl revision 8acca114eef1383702a6d6d97588e930cd650b9c
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 = '#XSLT'">
41        <xsl:text>XSLT.html</xsl:text>
42      </xsl:when>
43      <xsl:when test="$name = '#XML'">
44        <xsl:text>XMLinfo.html</xsl:text>
45      </xsl:when>
46      <xsl:when test="$name = '#Validation'">
47        <xsl:text>xmldtd.html</xsl:text>
48      </xsl:when>
49      <xsl:when test="$name = '#tree'">
50        <xsl:text>tree.html</xsl:text>
51      </xsl:when>
52      <xsl:when test="$name = '#library'">
53        <xsl:text>library.html</xsl:text>
54      </xsl:when>
55      <xsl:when test="$name = '#interface'">
56        <xsl:text>interface.html</xsl:text>
57      </xsl:when>
58      <xsl:when test="$name = '#Example'">
59        <xsl:text>example.html</xsl:text>
60      </xsl:when>
61      <xsl:when test="$name = '#Entities'">
62        <xsl:text>entities.html</xsl:text>
63      </xsl:when>
64      <xsl:when test="$name = '#architecture'">
65        <xsl:text>architecture.html</xsl:text>
66      </xsl:when>
67      <xsl:when test="$name = '#Namespaces'">
68        <xsl:text>namespaces.html</xsl:text>
69      </xsl:when>
70      <xsl:when test="$name = '#DOM'">
71        <xsl:text>DOM.html</xsl:text>
72      </xsl:when>
73      <xsl:when test="$name = '#Catalog'">
74        <xsl:text>catalog.html</xsl:text>
75      </xsl:when>
76      <xsl:when test="$name = '#Upgrading'">
77        <xsl:text>upgrade.html</xsl:text>
78      </xsl:when>
79      <xsl:when test="$name = '#Encodings'">
80        <xsl:text>encoding.html</xsl:text>
81      </xsl:when>
82      <xsl:when test="$name = '#IO'">
83        <xsl:text>xmlio.html</xsl:text>
84      </xsl:when>
85      <xsl:when test="$name = '#Memory'">
86        <xsl:text>xmlmem.html</xsl:text>
87      </xsl:when>
88      <xsl:when test="$name = '#Thread'">
89        <xsl:text>threads.html</xsl:text>
90      </xsl:when>
91      <xsl:when test="$name = '#FAQ'">
92        <xsl:text>FAQ.html</xsl:text>
93      </xsl:when>
94      <xsl:when test="$name = ''">
95        <xsl:text>unknown.html</xsl:text>
96      </xsl:when>
97      <xsl:otherwise>
98        <xsl:value-of select="$name"/>
99      </xsl:otherwise>
100    </xsl:choose>
101  </xsl:template>
102<!--
103 - The global title
104 -->
105  <xsl:variable name="globaltitle" select="string(/html/body/h1[1])"/>
106<!--
107 - The table of content
108 -->
109  <xsl:variable name="toc">
110    <ul><!-- style="margin-left: -1em" -->
111      <li><a href="index.html">Home</a></li>
112      <xsl:for-each select="/html/body/h2">
113        <xsl:variable name="filename">
114          <xsl:call-template name="filename">
115            <xsl:with-param name="name" select="concat('#', string(a[1]/@name))"/>
116          </xsl:call-template>
117        </xsl:variable>
118        <li>
119          <xsl:element name="a">
120            <xsl:attribute name="href">
121              <xsl:value-of select="$filename"/>
122            </xsl:attribute>
123            <xsl:value-of select="."/>
124          </xsl:element>
125        </li>
126      </xsl:for-each>
127      <li><a href="xml.html">flat page</a>, <a href="site.xsl">stylesheet</a></li>
128    </ul>
129  </xsl:variable>
130  <xsl:variable name="related">
131    <ul><!-- style="margin-left: -1em" -->
132      <li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li>
133      <li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li>
134      <li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li>
135      <li><a href="ftp://xmlsoft.org/">FTP</a></li>
136      <li><a href="http://www.fh-frankfurt.de/~igor/projects/libxml/">Windows binaries</a></li>
137      <li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li>
138      <li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml">Bug Tracker</a></li>
139    </ul>
140  </xsl:variable>
141  <xsl:template name="toc">
142    <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
143      <tr>
144        <td>
145          <table width="100%" border="0" cellspacing="1" cellpadding="3">
146            <tr>
147              <td colspan="1" bgcolor="#eecfa1" align="center">
148                <center>
149                  <b>Main Menu</b>
150                </center>
151              </td>
152            </tr>
153            <tr>
154              <td bgcolor="#fffacd">
155                <xsl:copy-of select="$toc"/>
156              </td>
157            </tr>
158          </table>
159          <table width="100%" border="0" cellspacing="1" cellpadding="3">
160            <tr>
161              <td colspan="1" bgcolor="#eecfa1" align="center">
162                <center>
163                  <b>Related links</b>
164                </center>
165              </td>
166            </tr>
167            <tr>
168              <td bgcolor="#fffacd">
169                <xsl:copy-of select="$related"/>
170              </td>
171            </tr>
172          </table>
173        </td>
174      </tr>
175    </table>
176  </xsl:template>
177  <xsl:template mode="head" match="title">
178    <title>
179      <xsl:apply-templates/>
180    </title>
181  </xsl:template>
182  <xsl:template mode="head" match="meta">
183</xsl:template>
184<!--
185 - Write the styles in the head
186 -->
187  <xsl:template name="style">
188    <style type="text/css"><xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
189TD {font-size: 14pt; font-family: Verdana,Arial,Helvetica}
190BODY {font-size: 14pt; font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
191H1 {font-size: 20pt; font-family: Verdana,Arial,Helvetica}
192H2 {font-size: 18pt; font-family: Verdana,Arial,Helvetica}
193H3 {font-size: 16pt; font-family: Verdana,Arial,Helvetica}
194A:link, A:visited, A:active { text-decoration: underline }
195<xsl:text disable-output-escaping="yes">--&gt;</xsl:text></style>
196  </xsl:template>
197<!--
198 - Write the title box on top
199 -->
200  <xsl:template name="titlebox">
201    <xsl:param name="title" select="'Main Page'"/>
202    <table border="0" width="100%" cellpadding="5" cellspacing="0" align="center">
203    <tr>
204    <td width="180">
205    <a href="http://www.gnome.org/"><img src="smallfootonly.gif" alt="Gnome Logo"/></a>
206    <a href="http://www.w3.org/Status"><img src="w3c.png" alt="W3C Logo"/></a>
207    <a href="http://www.redhat.com/"><img src="redhat.gif" alt="Red Hat Logo"/></a>
208    </td>
209    <td>
210    <table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000">
211      <tr>
212        <td>
213          <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd">
214            <tr>
215              <td align="center">
216                <xsl:element name="h1">
217                  <xsl:value-of select="$globaltitle"/>
218                </xsl:element>
219                <xsl:element name="h2">
220                  <xsl:value-of select="$title"/>
221                </xsl:element>
222              </td>
223            </tr>
224          </table>
225        </td>
226      </tr>
227    </table>
228    </td>
229    </tr>
230    </table>
231  </xsl:template>
232<!--
233 - Handling of nodes in the body before the first H2, table of content
234 - Everything is just copied over, except href which may get rewritten
235 - and h1/h2/a at the top level
236 -->
237  <xsl:template priority="2" mode="subcontent" match="a">
238    <xsl:variable name="filename">
239      <xsl:call-template name="filename">
240        <xsl:with-param name="name" select="string(@href)"/>
241      </xsl:call-template>
242    </xsl:variable>
243    <xsl:copy>
244      <xsl:attribute name="href">
245        <xsl:value-of select="$filename"/>
246      </xsl:attribute>
247      <xsl:apply-templates mode="subcontent" select="node()"/>
248    </xsl:copy>
249  </xsl:template>
250  <xsl:template mode="subcontent" match="@*|node()">
251    <xsl:copy>
252      <xsl:apply-templates mode="subcontent" select="@*|node()"/>
253    </xsl:copy>
254  </xsl:template>
255  <xsl:template mode="content" match="@*|node()">
256    <xsl:if test="name() != 'h1' and name() != 'h2'">
257      <xsl:copy>
258        <xsl:apply-templates mode="subcontent" select="@*|node()"/>
259      </xsl:copy>
260    </xsl:if>
261  </xsl:template>
262<!--
263 - Handling of nodes in the body after an H2
264 - Open a new file and dump all the siblings up to the next H2
265 -->
266  <xsl:template name="subfile">
267    <xsl:param name="header" select="following-sibling::h2[1]"/>
268    <xsl:variable name="filename">
269      <xsl:call-template name="filename">
270        <xsl:with-param name="name" select="concat('#', string($header/a[1]/@name))"/>
271      </xsl:call-template>
272    </xsl:variable>
273    <xsl:variable name="title">
274      <xsl:value-of select="$header"/>
275    </xsl:variable>
276    <xsl:document href="{$filename}" method="html" version="4.01" encoding="ISO-8859-1">
277      <html>
278        <head>
279          <xsl:call-template name="style"/>
280          <xsl:element name="title">
281            <xsl:value-of select="$title"/>
282          </xsl:element>
283        </head>
284        <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
285          <xsl:call-template name="titlebox">
286            <xsl:with-param name="title" select="$title"/>
287          </xsl:call-template>
288          <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
289            <tr>
290              <td bgcolor="#8b7765">
291                <table border="0" cellspacing="0" cellpadding="2" width="100%">
292                  <tr>
293                    <td valign="top" width="200" bgcolor="#8b7765">
294                      <xsl:call-template name="toc"/>
295                    </td>
296                    <td valign="top" bgcolor="#8b7765">
297                      <table border="0" cellspacing="0" cellpadding="1" width="100%">
298                        <tr>
299                          <td>
300                            <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
301                              <tr>
302                                <td>
303                                  <table border="0" cellpadding="3" cellspacing="1" width="100%">
304                                    <tr>
305                                      <td bgcolor="#fffacd">
306                                        <xsl:apply-templates mode="subfile" select="$header/following-sibling::*[preceding-sibling::h2[1] = $header         and name() != 'h2' ]"/>
307					<p><a href="mailto:daniel@veillard.com">Daniel Veillard</a></p>
308                                      </td>
309                                    </tr>
310                                  </table>
311                                </td>
312                              </tr>
313                            </table>
314                          </td>
315                        </tr>
316                      </table>
317                    </td>
318                  </tr>
319                </table>
320              </td>
321            </tr>
322          </table>
323        </body>
324      </html>
325    </xsl:document>
326  </xsl:template>
327  <xsl:template mode="subfile" match="@*|node()">
328    <xsl:copy>
329      <xsl:apply-templates mode="content" select="@*|node()"/>
330    </xsl:copy>
331  </xsl:template>
332<!--
333 - Handling of the initial body and head HTML document
334 -->
335  <xsl:template match="body">
336    <xsl:variable name="firsth2" select="/h2[1]"/>
337    <xsl:variable name="rest2" select="/h2[position()&gt;1]"/>
338    <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
339      <xsl:call-template name="titlebox">
340        <xsl:with-param name="title" select="'libxml'"/>
341      </xsl:call-template>
342      <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
343        <tr>
344          <td bgcolor="#8b7765">
345            <table border="0" cellspacing="0" cellpadding="2" width="100%">
346              <tr>
347                <td valign="top" width="200" bgcolor="#8b7765">
348                  <xsl:call-template name="toc"/>
349                </td>
350                <td valign="top" bgcolor="#8b7765">
351                  <table border="0" cellspacing="0" cellpadding="1" width="100%">
352                    <tr>
353                      <td>
354                        <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
355                          <tr>
356                            <td>
357                              <table border="0" cellpadding="3" cellspacing="1" width="100%">
358                                <tr>
359                                  <td bgcolor="#fffacd">
360                                    <xsl:apply-templates mode="content" select="($firsth2/preceding-sibling::*)"/>
361                                    <xsl:for-each select="/h2">
362                                      <xsl:call-template name="subfile">
363                                        <xsl:with-param name="header" select="."/>
364                                      </xsl:call-template>
365                                    </xsl:for-each>
366				    <p><a href="mailto:daniel@veillard.com">Daniel Veillard</a></p>
367                                  </td>
368                                </tr>
369                              </table>
370                            </td>
371                          </tr>
372                        </table>
373                      </td>
374                    </tr>
375                  </table>
376                </td>
377              </tr>
378            </table>
379          </td>
380        </tr>
381      </table>
382    </body>
383  </xsl:template>
384  <xsl:template match="head">
385    <head>
386      <xsl:call-template name="style"/>
387      <xsl:apply-templates mode="head"/>
388    </head>
389  </xsl:template>
390  <xsl:template match="html">
391    <html>
392      <xsl:apply-templates/>
393    </html>
394  </xsl:template>
395</xsl:stylesheet>
396