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