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