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