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"/>
5 - returns the filename associated to an ID in the original file
7 <xsl:template name="filename">
8 <xsl:param name="name" select="string(@href)"/>
10 <xsl:when test="$name = '#Introducti'">
11 <xsl:text>intro.html</xsl:text>
13 <xsl:when test="$name = '#Documentat'">
14 <xsl:text>docs.html</xsl:text>
16 <xsl:when test="$name = '#Reporting'">
17 <xsl:text>bugs.html</xsl:text>
19 <xsl:when test="$name = '#help'">
20 <xsl:text>help.html</xsl:text>
22 <xsl:when test="$name = '#Help'">
23 <xsl:text>help.html</xsl:text>
25 <xsl:when test="$name = '#Downloads'">
26 <xsl:text>downloads.html</xsl:text>
28 <xsl:when test="$name = '#News'">
29 <xsl:text>news.html</xsl:text>
31 <xsl:when test="$name = '#Contributi'">
32 <xsl:text>contribs.html</xsl:text>
34 <xsl:when test="$name = '#xsltproc'">
35 <xsl:text>xsltproc2.html</xsl:text>
37 <xsl:when test="$name = '#API'">
38 <xsl:text>API.html</xsl:text>
40 <xsl:when test="$name = '#Extensions'">
41 <xsl:text>extensions.html</xsl:text>
43 <xsl:when test="$name = '#Internals'">
44 <xsl:text>internals.html</xsl:text>
46 <xsl:when test="$name = ''">
47 <xsl:text>unknown.html</xsl:text>
50 <xsl:value-of select="$name"/>
55 - The table of content
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))"/>
67 <xsl:element name="a">
68 <xsl:attribute name="href">
69 <xsl:value-of select="$filename"/>
71 <xsl:value-of select="."/>
75 <li><a href="xslt.html">flat page</a>, <a href="site.xsl">stylesheet</a></li>
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>
92 <xsl:template name="toc">
93 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
96 <table width="100%" border="0" cellspacing="1" cellpadding="3">
98 <td colspan="1" bgcolor="#eecfa1" align="center">
105 <td bgcolor="#fffacd">
106 <xsl:copy-of select="$toc"/>
110 <table width="100%" border="0" cellspacing="1" cellpadding="3">
112 <td colspan="1" bgcolor="#eecfa1" align="center">
119 <td bgcolor="#fffacd">
120 <xsl:copy-of select="$related"/>
128 <xsl:template mode="head" match="title">
130 <xsl:apply-templates/>
133 <xsl:template mode="head" match="meta">
138 <xsl:variable name="globaltitle" select="string(/html/body/h1[1])"/>
140 - Write the styles in the head
142 <xsl:template name="style">
143 <style type="text/css"><xsl:text disable-output-escaping="yes"><!--</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">--></xsl:text></style>
153 - Write the title box on top
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">
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>
164 <table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000">
167 <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd">
170 <xsl:element name="h1">
171 <xsl:value-of select="$globaltitle"/>
173 <xsl:element name="h2">
174 <xsl:value-of select="$title"/>
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
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)"/>
198 <xsl:attribute name="href">
199 <xsl:value-of select="$filename"/>
201 <xsl:apply-templates mode="subcontent" select="node()"/>
204 <xsl:template mode="subcontent" match="@*|node()">
206 <xsl:apply-templates mode="subcontent" select="@*|node()"/>
209 <xsl:template mode="content" match="@*|node()">
210 <xsl:if test="name() != 'h1' and name() != 'h2'">
212 <xsl:apply-templates mode="subcontent" select="@*|node()"/>
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
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))"/>
227 <xsl:variable name="title">
228 <xsl:value-of select="$header"/>
230 <xsl:document href="{$filename}" method="html" version="4.01" encoding="ISO-8859-1">
233 <xsl:call-template name="style"/>
234 <xsl:element name="title">
235 <xsl:value-of select="$title"/>
238 <body bgcolor="#8b7765" text="#000000" link="#000000" vlink="#000000">
239 <xsl:call-template name="titlebox">
240 <xsl:with-param name="title" select="$title"/>
242 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
244 <td bgcolor="#8b7765">
245 <table border="0" cellspacing="0" cellpadding="2" width="100%">
247 <td valign="top" width="200" bgcolor="#8b7765">
248 <xsl:call-template name="toc"/>
250 <td valign="top" bgcolor="#8b7765">
251 <table border="0" cellspacing="0" cellpadding="1" width="100%">
254 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
257 <table border="0" cellpadding="3" cellspacing="1" width="100%">
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>
281 <xsl:template mode="subfile" match="@*|node()">
283 <xsl:apply-templates mode="content" select="@*|node()"/>
287 - Handling of the initial body and head HTML document
289 <xsl:template match="body">
290 <xsl:variable name="firsth2" select="./h2[1]"/>
291 <xsl:variable name="rest2" select="./h2[position()>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'"/>
296 <table border="0" cellpadding="4" cellspacing="0" width="100%" align="center">
298 <td bgcolor="#8b7765">
299 <table border="0" cellspacing="0" cellpadding="2" width="100%">
301 <td valign="top" width="200" bgcolor="#8b7765">
302 <xsl:call-template name="toc"/>
304 <td valign="top" bgcolor="#8b7765">
305 <table border="0" cellspacing="0" cellpadding="1" width="100%">
308 <table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000">
311 <table border="0" cellpadding="3" cellspacing="1" width="100%">
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="."/>
320 <p><a href="mailto:daniel@veillard.com">Daniel Veillard</a></p>
338 <xsl:template match="head">
340 <xsl:call-template name="style"/>
341 <xsl:apply-templates mode="head"/>
344 <xsl:template match="html">
346 <xsl:apply-templates/>