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