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"/>
7 <xsl:variable name="href_base" select="''"/>
10 - returns the filename associated to an ID in the original file
12 <xsl:template name="filename">
13 <xsl:param name="name" select="string(@href)"/>
15 <xsl:when test="$name = '#Introducti'">
16 <xsl:text>intro.html</xsl:text>
18 <xsl:when test="$name = '#Documentat'">
19 <xsl:text>docs.html</xsl:text>
21 <xsl:when test="$name = '#Reporting'">
22 <xsl:text>bugs.html</xsl:text>
24 <xsl:when test="$name = '#help'">
25 <xsl:text>help.html</xsl:text>
27 <xsl:when test="$name = '#Help'">
28 <xsl:text>help.html</xsl:text>
30 <xsl:when test="$name = '#Downloads'">
31 <xsl:text>downloads.html</xsl:text>
33 <xsl:when test="$name = '#News'">
34 <xsl:text>news.html</xsl:text>
36 <xsl:when test="$name = '#Contributi'">
37 <xsl:text>contribs.html</xsl:text>
39 <xsl:when test="$name = '#xsltproc'">
40 <xsl:text>xsltproc2.html</xsl:text>
42 <xsl:when test="$name = '#API'">
43 <xsl:text>API.html</xsl:text>
45 <xsl:when test="$name = '#Extensions'">
46 <xsl:text>extensions.html</xsl:text>
48 <xsl:when test="$name = '#Internals'">
49 <xsl:text>internals.html</xsl:text>
51 <xsl:when test="$name = '#DocBook'">
52 <xsl:text>docbook.html</xsl:text>
54 <xsl:when test="$name = '#FAQ'">
55 <xsl:text>FAQ.html</xsl:text>
57 <xsl:when test="$name = '#Python'">
58 <xsl:text>python.html</xsl:text>
60 <xsl:when test="$name = ''">
61 <xsl:text>unknown.html</xsl:text>
64 <xsl:value-of select="$name"/>
69 - The table of content
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 ..."/>
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))"/>
86 <xsl:element name="a">
87 <xsl:attribute name="href">
88 <xsl:value-of select="$filename"/>
90 <xsl:value-of select="."/>
94 <li><a href="xslt.html">flat page</a>, <a href="site.xsl">stylesheet</a></li>
97 <xsl:variable name="api">
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>
106 <xsl:variable name="related">
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>
123 <xsl:template name="develtoc">
124 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
127 <table width="100%" border="0" cellspacing="1" cellpadding="3">
129 <td colspan="1" bgcolor="#eecfa1" align="center">
136 <td bgcolor="#fffacd">
137 <xsl:copy-of select="$toc"/>
141 <table width="100%" border="0" cellspacing="1" cellpadding="3">
143 <td colspan="1" bgcolor="#eecfa1" align="center">
150 <td bgcolor="#fffacd">
151 <xsl:copy-of select="$related"/>
155 <table width="100%" border="0" cellspacing="1" cellpadding="3">
157 <td colspan="1" bgcolor="#eecfa1" align="center">
164 <td bgcolor="#fffacd">
165 <xsl:copy-of select="$api"/>
173 <xsl:template mode="head" match="title">
175 <xsl:apply-templates/>
178 <xsl:template mode="head" match="meta">
183 <xsl:variable name="globaltitle" select="string(/html/body/h1[1])"/>
185 - Write the styles in the head
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 }
198 - Write the title box on top
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">
205 <a href="http://swpat.ffii.org/"><img src="{$href_base}epatents.png" alt="Action against software patents"/></a>
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>
211 <a href="http://xmlsoft.org/XSLT/"><img src="{$href_base}Libxslt-Logo-180x168.gif" alt="Made with Libxslt Logo"/></a>
215 <table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000">
218 <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd">
221 <xsl:element name="h1">
222 <xsl:value-of select="$globaltitle"/>
224 <xsl:element name="h2">
225 <xsl:value-of select="$title"/>
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
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)"/>
249 <xsl:attribute name="href">
250 <xsl:value-of select="$filename"/>
252 <xsl:apply-templates mode="subcontent" select="node()"/>
255 <xsl:template mode="subcontent" match="@*|node()">
257 <xsl:apply-templates mode="subcontent" select="@*|node()"/>
260 <xsl:template mode="content" match="@*|node()">
261 <xsl:if test="name() != 'h1' and name() != 'h2'">
263 <xsl:apply-templates mode="subcontent" select="@*|node()"/>
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
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))"/>
278 <xsl:variable name="title">
279 <xsl:value-of select="$header"/>
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">
286 <xsl:call-template name="style"/>
287 <xsl:element name="title">
288 <xsl:value-of select="$title"/>
291 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
292 <xsl:call-template name="titlebox">
293 <xsl:with-param name="title" select="$title"/>
295 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
297 <td bgcolor="#8b7765">
298 <table border="0" cellspacing="0" cellpadding="2" width="100%">
300 <td valign="top" width="200" bgcolor="#8b7765">
301 <xsl:call-template name="develtoc"/>
303 <td valign="top" bgcolor="#8b7765">
304 <table border="0" cellspacing="0" cellpadding="1" width="100%">
307 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
310 <table border="0" cellpadding="3" cellspacing="1" width="100%">
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>
334 <xsl:template mode="subfile" match="@*|node()">
336 <xsl:apply-templates mode="content" select="@*|node()"/>
340 - Handling of the initial body and head HTML document
342 <xsl:template match="body">
343 <xsl:variable name="firsth2" select="./h2[1]"/>
344 <xsl:variable name="rest2" select="./h2[position()>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'"/>
349 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
351 <td bgcolor="#8b7765">
352 <table border="0" cellspacing="0" cellpadding="2" width="100%">
354 <td valign="top" width="200" bgcolor="#8b7765">
355 <xsl:call-template name="develtoc"/>
357 <td valign="top" bgcolor="#8b7765">
358 <table border="0" cellspacing="0" cellpadding="1" width="100%">
361 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
364 <table border="0" cellpadding="3" cellspacing="1" width="100%">
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="."/>
373 <p><a href="bugs.html">Daniel Veillard</a></p>
391 <xsl:template match="head">
393 <xsl:call-template name="style"/>
394 <xsl:apply-templates mode="head"/>
397 <xsl:template match="html">
399 <xsl:apply-templates/>