source: tags/arb_5.3/HELP_SOURCE/to_html.xsl

Last change on this file was 7022, checked in by westram, 14 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.7 KB
Line 
1
2<!DOCTYPE xsl:stylesheet [
3          <!ENTITY nbsp "&#160;">
4          <!ENTITY acute "&#180;">
5          <!ENTITY dotwidth "20">
6          <!ENTITY dotheight "16">
7          <!ENTITY br "&#xa;">
8          ]>
9
10
11<!-- used to create ARB help in HTML format -->
12
13<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
14               version="1.0"
15               >
16
17  <!--  <xsl:output method="html" encoding="iso-8859-1" indent="no"/>-->
18  <!--<xsl:output method="html" indent="no"/>-->
19  <!--<xsl:output method="html" encoding="iso-8859-1" indent="yes"/>-->
20  <xsl:output method="html" indent="no"/>
21
22  <xsl:param name="myname"/>
23  <xsl:param name="xml_location"/>
24
25  <!-- includes -->
26
27  <xsl:include href="date.xsl"/>
28
29  <xsl:variable name="rootpath">
30    <xsl:choose>
31      <xsl:when test="string-length(substring-before($myname,'/'))&gt;0">../</xsl:when>
32      <xsl:otherwise></xsl:otherwise>
33    </xsl:choose>
34  </xsl:variable>
35
36  <xsl:variable name="postscriptpath">
37    <xsl:value-of select="$rootpath"/><xsl:text>../help/</xsl:text>
38  </xsl:variable>
39  <xsl:variable name="pdfpath"><xsl:value-of select="$postscriptpath"/></xsl:variable>
40
41  <xsl:variable name="tableBorder">0</xsl:variable>
42
43  <xsl:variable name="author">ARB development</xsl:variable>
44  <xsl:variable name="maildomain">arb-home.de</xsl:variable>
45
46  <xsl:variable name="fontColor">black</xsl:variable>
47  <xsl:variable name="backgroundColor">white</xsl:variable>
48  <xsl:variable name="linkColor">blue</xsl:variable>
49  <xsl:variable name="visitedLinkColor">green</xsl:variable>
50  <xsl:variable name="activeLinkColor">red</xsl:variable>
51  <xsl:variable name="externalLinkColor">#aa0088</xsl:variable>
52
53  <xsl:variable name="linkSectionsColor">#ccccff</xsl:variable>
54
55  <xsl:variable name="lb"><xsl:text>&br;</xsl:text></xsl:variable> <!--used to detect line-breaks in XML-->
56
57  <!-- =============== -->
58  <!--     warning     -->
59  <!-- =============== -->
60
61  <xsl:template name="error">
62    <xsl:param name="text" select="'Unknown error'"/>
63    <xsl:message terminate="yes"><xsl:value-of select="$text"/></xsl:message>
64  </xsl:template>
65
66  <!-- ============ -->
67  <!--    LINKs     -->
68  <!-- ============ -->
69
70  <!--insert-link-->
71  <xsl:template name="insert-link">
72
73    <xsl:param name="address"/>
74    <xsl:param name="linktext"/>
75
76    <xsl:variable name="external">
77      <xsl:choose>
78        <xsl:when test="starts-with(substring-before($address,'.arb-home.de/'),'http://')">0</xsl:when><!--all arb-home-subdomains-->
79        <xsl:when test="starts-with($address,'http://arb-home.de/')">0</xsl:when>
80        <xsl:when test="starts-with($address,'http://')">1</xsl:when>
81        <xsl:otherwise>0</xsl:otherwise>
82      </xsl:choose>
83    </xsl:variable>
84
85    <xsl:choose>
86      <xsl:when test="$external = 1">
87        <!--if we have an external link -> create popup window-->
88        <A href="{$address}" target="_blank"><FONT color="{$externalLinkColor}"><xsl:value-of select="$linktext"/></FONT></A>
89      </xsl:when>
90      <xsl:otherwise>
91        <A href="{$address}"><xsl:value-of select="$linktext"/></A>
92      </xsl:otherwise>
93    </xsl:choose>
94  </xsl:template>
95
96  <!--insert-email-link-->
97  <xsl:template name="insert-email-link">
98    <xsl:param  name="linktext"/>
99    <xsl:param  name="address" select="arb"/>
100    <xsl:param  name="subject"/>
101
102    <xsl:variable name="add">
103      <xsl:choose>
104        <xsl:when test="string-length(substring-before($address,'@'))>0"><xsl:value-of select="$address"/></xsl:when>
105        <xsl:otherwise><xsl:value-of select="$address"/>@<xsl:value-of select="$maildomain"/></xsl:otherwise>
106      </xsl:choose>
107    </xsl:variable>
108    <xsl:variable name="addsubj">
109      <xsl:choose>
110        <xsl:when test="string-length($subject)>0"><xsl:value-of select="$add"/>?subject=<xsl:value-of select="$subject"/></xsl:when>
111        <xsl:otherwise><xsl:value-of select="$add"/></xsl:otherwise>
112      </xsl:choose>
113    </xsl:variable>
114    <A href="mailto:{$addsubj}">
115      <xsl:choose>
116        <xsl:when test="string-length($linktext)>0"><xsl:value-of select="$linktext"/></xsl:when>
117        <xsl:otherwise><xsl:value-of select="$add"/></xsl:otherwise>
118      </xsl:choose>
119    </A>
120  </xsl:template>
121
122
123  <!-- ============================== -->
124  <!--     insert document header     -->
125  <!-- ============================== -->
126  <xsl:template name="header" >
127    <xsl:param name="title" select="'Untitled'"/>
128    <xsl:comment>Generated from XML - XSLT-Stylesheet by Ralf Westram (ralf@arb-home.de) </xsl:comment>
129    <HEAD>
130      <META NAME="Author" CONTENT="{$author}"/>
131      <meta http-equiv="expires" content="86400"/>
132      <!--<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>   this is added automatically   --> 
133      <!--<meta http-equiv="expires" content="86400"/>-->
134      <TITLE>ARB help: <xsl:value-of select="$title"/></TITLE>
135    </HEAD>
136  </xsl:template>
137
138  <!-- ======================== -->
139  <!--     link-to-document     -->
140  <!-- ======================== -->
141  <xsl:template name="link-to-document">
142    <xsl:param name="doc"/>
143    <xsl:param name="type"/>
144    <xsl:param name="missing"/>
145    <xsl:param name="quote"/>
146
147    <xsl:choose>
148      <xsl:when test="$type='ps'">
149        <A href="{concat($postscriptpath,$doc,'.gz')}">
150          <xsl:value-of select="$doc"/> (Postscript)
151        </A>
152      </xsl:when>
153      <xsl:when test="$type='pdf'">
154        <A href="{concat($pdfpath,$doc,'.gz')}">
155          <xsl:value-of select="$doc"/> (PDF)
156        </A>
157      </xsl:when>
158      <xsl:when test="$type='hlp'">
159        <xsl:variable name="docbase">
160          <xsl:value-of select="substring-before($doc,'.hlp')"/>
161        </xsl:variable>
162        <A href="{concat($rootpath,$docbase)}.html">
163          <xsl:choose>
164            <xsl:when test="$missing='1'">
165              <FONT color="red"><xsl:value-of select="concat('Missing Link to ',$doc)"/></FONT>
166            </xsl:when>
167            <xsl:otherwise>
168              <xsl:for-each select="document(concat($xml_location,'/',$docbase,'.xml'))">
169                <xsl:for-each select="PAGE/TITLE">
170                  <xsl:if test="$quote='1'">&acute;</xsl:if>
171                  <xsl:copy-of select="normalize-space(text())"/>
172                  <xsl:if test="$quote='1'">&acute;</xsl:if>
173                </xsl:for-each>
174              </xsl:for-each>
175            </xsl:otherwise>
176          </xsl:choose>
177        </A>
178      </xsl:when>
179      <xsl:otherwise>
180        <xsl:message terminate="yes">Illegal document type '<xsl:value-of select="$type"/>' in link-to-document</xsl:message>
181      </xsl:otherwise>
182    </xsl:choose>
183  </xsl:template>
184
185  <!-- =============== -->
186  <!--     uplinks     -->
187  <!-- =============== -->
188
189  <xsl:template match="UP" mode="uplinks"><LI><xsl:call-template name="link-to-document">
190        <xsl:with-param name="doc" select="@dest"/>
191        <xsl:with-param name="type" select="@type"/>
192        <xsl:with-param name="missing" select="@missing"/>
193      </xsl:call-template></LI></xsl:template>
194
195  <xsl:template match="*" mode="uplinks">
196  </xsl:template>
197
198  <!-- ================ -->
199  <!--     sublinks     -->
200  <!-- ================ -->
201
202  <xsl:template match="SUB" mode="sublinks">
203    <LI>
204      <xsl:call-template name="link-to-document">
205        <xsl:with-param name="doc" select="@dest"/>
206        <xsl:with-param name="type" select="@type"/>
207        <xsl:with-param name="missing" select="@missing"/>
208      </xsl:call-template>
209    </LI>
210  </xsl:template>
211
212  <xsl:template match="*" mode="sublinks">
213  </xsl:template>
214
215  <!-- =================== -->
216  <!--     reflow mode     -->
217  <!-- =================== -->
218
219  <xsl:template match="text()" mode="reflow">
220    <xsl:value-of select="."/>
221  </xsl:template>
222  <xsl:template match="LINK" mode="reflow">
223    <xsl:apply-templates select="." mode="link-recursion"/>
224  </xsl:template>
225  <xsl:template match="*" mode="reflow">
226    <xsl:call-template name="error"><xsl:with-param name="text">Illegal TAG <xsl:value-of select="name()"/> in mode &acute;reflow&acute;</xsl:with-param></xsl:call-template>
227  </xsl:template>
228
229  <!-- ========================= -->
230  <!--     preformatted mode     -->
231  <!-- ========================= -->
232
233<!--  <xsl:template match="text()" mode="preformatted-old"><PRE><FONT color="navy"><xsl:value-of select="substring-after(.,$lb)"/></FONT></PRE></xsl:template>-->
234
235  <xsl:template match="text()" mode="preformatted">
236    <xsl:variable name="before_lf"><xsl:value-of select="substring-before(.,$lb)"/></xsl:variable>
237
238    <xsl:choose>
239      <xsl:when test="normalize-space($before_lf)=''">
240        <xsl:variable name="after_lf"><xsl:value-of select="substring-after(.,$lb)"/></xsl:variable>
241        <xsl:choose>
242          <xsl:when test="normalize-space($after_lf)=''"><xsl:value-of select="."/></xsl:when>
243          <xsl:otherwise><xsl:value-of select="$after_lf"/></xsl:otherwise>
244        </xsl:choose>
245      </xsl:when>
246      <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
247    </xsl:choose>
248  </xsl:template>
249  <xsl:template match="LINK" mode="preformatted">
250    <xsl:apply-templates select="." mode="link-recursion"/>
251  </xsl:template>
252  <xsl:template match="*" mode="preformatted">
253    <xsl:call-template name="error"><xsl:with-param name="text">Illegal TAG <xsl:value-of select="name()"/> in mode &acute;preformatted&acute;</xsl:with-param></xsl:call-template>
254  </xsl:template>
255
256
257  <xsl:template match="LINK" mode="link-recursion">
258    <xsl:variable name="quoted">
259      <xsl:choose>
260        <xsl:when test="@quoted='0'">0</xsl:when>
261        <xsl:otherwise>1</xsl:otherwise>
262      </xsl:choose>
263    </xsl:variable>
264    <xsl:choose>
265      <xsl:when test="@type='hlp' or @type='ps' or @type='pdf'">
266        <xsl:call-template name="link-to-document">
267          <xsl:with-param name="doc" select="@dest"/>
268          <xsl:with-param name="type" select="@type"/>
269          <xsl:with-param name="missing" select="@missing"/>
270          <xsl:with-param name="quote" select="$quoted"/>
271        </xsl:call-template>
272      </xsl:when>
273      <xsl:when test="@type='www'">
274        <xsl:call-template name="insert-link">
275          <xsl:with-param name="linktext"><xsl:value-of select="@dest"/></xsl:with-param>
276          <xsl:with-param name="address"><xsl:value-of select="@dest"/></xsl:with-param>
277        </xsl:call-template>
278      </xsl:when>
279      <xsl:when test="@type='email'">
280        <xsl:call-template name="insert-email-link">
281          <xsl:with-param name="linktext"><xsl:value-of select="@dest"/></xsl:with-param>
282          <xsl:with-param name="address"><xsl:value-of select="@dest"/></xsl:with-param>
283          <xsl:with-param name="subject" select="concat('Concerning helppage ',$myname)"/>
284        </xsl:call-template>
285      </xsl:when>
286      <xsl:otherwise>
287        <xsl:call-template name="error"><xsl:with-param name="text">Unknown type '<xsl:value-of select="@type"/>'</xsl:with-param></xsl:call-template>
288      </xsl:otherwise>
289    </xsl:choose>
290  </xsl:template>
291
292  <xsl:template match="T" mode="condensed">
293    <xsl:choose>
294      <xsl:when test="@reflow='1'">
295        <xsl:apply-templates mode="reflow"/>
296      </xsl:when>
297      <xsl:otherwise>
298        <PRE><FONT color="navy" size="-1"><xsl:apply-templates mode="preformatted"/></FONT></PRE>
299      </xsl:otherwise>
300    </xsl:choose>
301  </xsl:template>
302
303  <xsl:template match="*" mode="condensed">
304    <xsl:apply-templates select="."/>
305  </xsl:template>
306
307  <xsl:template match="T">
308    <xsl:choose>
309      <xsl:when test="@reflow='1'">
310        <B><xsl:apply-templates mode="reflow"/></B>
311        <BR/>
312      </xsl:when>
313      <xsl:otherwise>
314        <PRE><FONT color="navy" size="-1"><xsl:apply-templates mode="preformatted"/></FONT></PRE>
315      </xsl:otherwise>
316    </xsl:choose>
317  </xsl:template>
318
319
320  <xsl:template match="ENTRY">
321    <LI>
322      <xsl:apply-templates mode="condensed"/>
323    </LI>
324  </xsl:template>
325
326  <xsl:template match="P">
327    <P style="margin-left:+10pt"><xsl:apply-templates mode="condensed"/></P>
328  </xsl:template>
329
330  <xsl:template match="ENUM">
331    <OL>
332      <xsl:apply-templates/>
333    </OL>
334    <BR/>
335  </xsl:template>
336  <xsl:template match="LIST">
337    <UL>
338      <xsl:apply-templates/>
339    </UL>
340    <BR/>
341  </xsl:template>
342
343  <xsl:template match="P" mode="top-level"><P><xsl:apply-templates/></P></xsl:template>
344  <xsl:template match="T|ENUM|LIST" mode="top-level"><xsl:apply-templates select="."/></xsl:template>
345
346  <xsl:template match="SECTION" mode="main">
347    <A name="{translate(@name,' ','_')}"></A>
348    <H2><xsl:value-of select="@name"/></H2>
349    <TABLE width="100%" border="{$tableBorder}">
350      <TR>
351        <TD align="right">
352          <TABLE width="97%" border="{$tableBorder}">
353            <TR>
354              <TD>
355                <xsl:apply-templates mode="top-level"/>
356              </TD>
357            </TR>
358<!--            <TR><TD>&nbsp;</TD></TR>-->
359            <TR><TD>&nbsp;</TD></TR>
360          </TABLE>
361        </TD>
362      </TR>
363    </TABLE>
364  </xsl:template>
365
366  <xsl:template match="SECTION" mode="content">
367    <LI><A href="#{translate(@name,' ','_')}"><xsl:value-of select="@name"/></A></LI>
368  </xsl:template>
369
370  <!-- ================================ -->
371  <!--     PAGE document wide layout    -->
372  <!-- ================================ -->
373
374  <xsl:template match="PAGE">
375    <HTML>
376      <xsl:variable name="title">
377        <xsl:for-each select="TITLE">
378          <xsl:value-of select="text()"/>
379        </xsl:for-each>
380      </xsl:variable>
381      <xsl:call-template name="header">
382        <xsl:with-param name="title" select="$title"/>
383      </xsl:call-template>
384      <BODY LEFTMARGIN="10" TEXT="{$fontColor}" BGCOLOR="{$backgroundColor}" LINK="{$linkColor}" VLINK="{$visitedLinkColor}" ALINK="{$activeLinkColor}">
385        <TABLE width="95%">
386          <TR>
387            <TD align="left" valign="top">
388              <!-- Search Google -->
389              <FORM method="GET" action="http://www.google.com/search" name="google">
390                <A HREF="http://www.google.com">
391                  <IMG SRC="Logo_25wht.gif" width="75" height="32" border="0" ALT="Google" align="absmiddle"/>
392                </A>
393                <INPUT TYPE="hidden" name="q"/>
394                <INPUT TYPE="hidden" name="hl" value="en"/>
395                <INPUT TYPE="hidden" name="as_sitesearch" value="help.arb-home.de"/>
396                <INPUT TYPE="text" name="q2" size="31" maxlength="255"/>
397                <INPUT type="submit" name="btnG" VALUE="Search help" onClick="google.q.value=google.q2.value;return true;"/>
398                <INPUT type="submit" name="btnG" VALUE="Search site" onClick="google.as_sitesearch.value='arb-home.de';google.q.value=google.q2.value;return true;"/>
399              </FORM>
400              <!-- Search Google -->
401            </TD>
402            <TD valign="top" align="right">
403              <FONT size="-1">
404                <NOBR>More docs on the
405                <xsl:call-template name="insert-link">
406                  <xsl:with-param name="linktext" select="'ARB website'"/>
407                  <xsl:with-param name="address" select="'http://rtfm.arb-home.de/'"/>
408                </xsl:call-template>.</NOBR><BR/>
409                See also <A href="{concat($rootpath,'help_index')}.html">index</A> of helppages.<BR/>
410                Last update on <xsl:value-of select="$date"/>.
411              </FONT>
412            </TD>
413          </TR>
414        </TABLE>
415        <TABLE border="{$tableBorder}" width="98%" align="center">
416          <TR bgcolor="{$linkSectionsColor}">
417            <TD valign="top" width="50%">Main topics:<BR/>
418              <UL><xsl:apply-templates mode="uplinks"/></UL>
419            </TD>
420            <TD valign="top">Related topics:<BR/>
421              <UL><xsl:apply-templates mode="sublinks"/></UL>
422            </TD>
423          </TR>
424          <TR>
425            <TD colspan="2">
426              <H1><xsl:value-of select="$title"/></H1>
427              <UL><xsl:apply-templates select="SECTION" mode="content"/></UL>
428              <xsl:apply-templates select="SECTION" mode="main"/>
429            </TD>
430          </TR>
431        </TABLE>
432      </BODY>
433    </HTML>
434  </xsl:template>
435
436  <!-- ============ -->
437  <!--     text()   (should be last template)  -->
438  <!-- ============ -->
439
440  <xsl:template match="text()|*">
441   <xsl:choose>
442     <!-- tags-->
443     <xsl:when test="string-length(name())>0">
444       <xsl:call-template name="error"><xsl:with-param name="text">Unbekannter TAG <xsl:value-of select="name()"/></xsl:with-param></xsl:call-template>
445     </xsl:when>
446     <!-- text() -->
447     <xsl:otherwise>
448       <xsl:variable name="self"><xsl:value-of select="."/></xsl:variable>
449       <xsl:choose>
450         <!--allow empty text-->
451         <xsl:when test="normalize-space($self)=''"></xsl:when>
452         <xsl:otherwise>
453           <!--           {<xsl:value-of select="."/>}-->
454           <xsl:call-template name="error"><xsl:with-param name="text">Unexpected text</xsl:with-param></xsl:call-template>
455         </xsl:otherwise>
456       </xsl:choose>
457     </xsl:otherwise>
458   </xsl:choose>
459  </xsl:template>
460
461
462</xsl:transform>
463
Note: See TracBrowser for help on using the repository browser.