source: branches/help/HELP_SOURCE/to_help.xsl

Last change on this file was 18818, checked in by westram, 3 years ago
  • add help page bugtracker explaining howto access tickets.
  • count references to tickets
    • insert link to bugtracker, if tickets referenced.
  • in change log: reference online html version containing links to tickets.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.1 KB
Line 
1<?xml version="1.0"?>
2
3<!--          <!ENTITY acute "&#180;">-->
4
5<!DOCTYPE xsl:stylesheet [
6          <!ENTITY nbsp "&#160;">
7          <!ENTITY acute "&#39;">
8          <!ENTITY dotwidth "20">
9          <!ENTITY dotheight "16">
10          <!ENTITY tab "&#x9;">
11          <!ENTITY br "&#xa;">
12          ]>
13
14
15<!-- used to create ARB help in internal format -->
16
17
18<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
19               version="1.0"
20               >
21
22<!--  <xsl:output method="text" encoding='iso-8859-15'/>-->
23  <xsl:output method="text"/>
24
25  <xsl:param name="myname"/>
26  <xsl:param name="xml_location"/>
27
28  <!-- includes -->
29
30  <xsl:include href="date.xsl"/>
31
32  <xsl:variable name="rootpath">
33    <xsl:choose>
34      <xsl:when test="string-length(substring-before($myname,'/'))&gt;0">../</xsl:when>
35      <xsl:otherwise></xsl:otherwise>
36    </xsl:choose>
37  </xsl:variable>
38
39  <xsl:variable name="author">ARB development</xsl:variable>
40  <xsl:variable name="maildomain">arb-home.de</xsl:variable>
41
42  <xsl:variable name="width" select="75"/> <!--columns in text output (applies only to reflown text)-->
43
44  <xsl:variable name="lb"><xsl:text>&br;</xsl:text></xsl:variable> <!--used to detect line-breaks in XML-->
45
46  <!-- =============== -->
47  <!--     warning     -->
48  <!-- =============== -->
49
50  <xsl:template name="error">
51    <xsl:param name="text" select="'Unknown error'"/>
52    <xsl:message terminate="yes">Error: <xsl:value-of select="$text"/></xsl:message>
53  </xsl:template>
54
55  <!-- ============ -->
56  <!--    LINKs     -->
57  <!-- ============ -->
58
59  <!--insert-link-->
60  <xsl:template name="insert-link">
61    <xsl:param name="address"/>
62    <xsl:param name="linktext"/>
63
64    <xsl:copy-of select="$address"/>
65<!--    [see: <xsl:value-of select="$address"/><xsl:text>]</xsl:text>-->
66  </xsl:template>
67
68  <!--insert-email-link-->
69  <xsl:template name="insert-email-link">
70    <xsl:param  name="linktext"/>
71    <xsl:param  name="address" select="arb"/>
72    <xsl:param  name="subject"/>
73
74
75    <xsl:variable name="add">
76      <xsl:choose>
77        <xsl:when test="string-length(substring-before($address,'@'))>0"><xsl:value-of select="$address"/></xsl:when>
78        <xsl:otherwise><xsl:value-of select="$address"/>@<xsl:value-of select="$maildomain"/></xsl:otherwise>
79      </xsl:choose>
80    </xsl:variable>
81
82    <xsl:value-of select="$linktext"/> [mailto: <xsl:value-of select="$add"/>
83    <xsl:text>  subject: &acute;</xsl:text>
84    <xsl:value-of select="$subject"/>
85    <xsl:text>&acute;]</xsl:text>
86
87  </xsl:template>
88
89  <!-- ======================== -->
90  <!--     link-to-document     -->
91  <!-- ======================== -->
92  <xsl:template name="link-to-document">
93    <xsl:param name="doc"/>
94    <xsl:param name="missing"/>
95    <xsl:param name="type"/>
96
97    <xsl:choose>
98      <xsl:when test="$type='ps'">
99        <xsl:text>Postscript: </xsl:text>
100        <xsl:value-of select="$doc"/>
101      </xsl:when>
102      <xsl:when test="$type='pdf'">
103        <xsl:text>PDF: </xsl:text>
104        <xsl:value-of select="$doc"/>
105      </xsl:when>
106      <xsl:when test="$type='hlp'">
107        <xsl:variable name="docbase">
108          <xsl:value-of select="substring-before($doc,'.hlp')"/>
109        </xsl:variable>
110        <xsl:choose>
111          <xsl:when test="$missing='1'">
112            <xsl:value-of select="concat('Missing Link to ',$docbase,'.hlp')"/>
113          </xsl:when>
114          <xsl:otherwise>
115            <xsl:for-each select="document(concat($xml_location,'/',$docbase,'.xml'))">
116              <xsl:for-each select="PAGE/TITLE">&acute;<xsl:copy-of select="normalize-space(text())"/>&acute;</xsl:for-each>
117            </xsl:for-each>
118          </xsl:otherwise>
119        </xsl:choose>
120      </xsl:when>
121      <xsl:otherwise>
122        <xsl:call-template name="error"><xsl:with-param name="text">Unhandled document link type '<xsl:value-of select="$type"/>' in link-to-document</xsl:with-param></xsl:call-template>
123      </xsl:otherwise>
124    </xsl:choose>
125  </xsl:template>
126
127  <!-- ==================== -->
128  <!--     up/sublinks      -->
129
130  <xsl:template name="help-link">
131    <xsl:param name="dest"/>
132
133    <xsl:value-of select="$dest"/>
134    <xsl:text>&br;</xsl:text>
135  </xsl:template>
136
137  <xsl:template name="insert-topic">
138    <xsl:param name="type"/>
139    <xsl:param name="dest"/>
140
141    <xsl:value-of select="$type"/>
142    <xsl:text>                 </xsl:text>
143    <xsl:call-template name="help-link">
144      <xsl:with-param name="dest" select="$dest"/>
145    </xsl:call-template>
146  </xsl:template>
147
148  <xsl:template match="UP" mode="uplinks">
149    <xsl:call-template name="insert-topic">
150      <xsl:with-param name="type" select="'UP '"/>
151      <xsl:with-param name="dest" select="@dest"/>
152    </xsl:call-template>
153  </xsl:template>
154  <xsl:template match="*|text()" mode="uplinks"></xsl:template>
155
156  <xsl:template match="SUB" mode="sublinks">
157    <xsl:call-template name="insert-topic">
158      <xsl:with-param name="type" select="'SUB'"/>
159      <xsl:with-param name="dest" select="@dest"/>
160    </xsl:call-template>
161  </xsl:template>
162  <xsl:template match="*|text()" mode="sublinks"></xsl:template>
163
164  <!-- ==================== -->
165  <!--     indentation      -->
166
167  <xsl:template match="ENTRY|P" mode="calc-indent">
168    <xsl:text>    </xsl:text><!--this defines the indentation per level-->
169    <xsl:apply-templates mode="calc-indent" select=".."/>
170  </xsl:template>
171  <xsl:template match="T|ENUM|LIST" mode="calc-indent">
172    <xsl:apply-templates mode="calc-indent" select=".."/>
173  </xsl:template>
174  <xsl:template match="SECTION" mode="calc-indent"></xsl:template>
175
176  <xsl:template name="find-last-space">
177    <xsl:param name="text"/>
178    <xsl:param name="len" select="string-length($text)"/>
179
180    <xsl:variable name="beforelen" select="string-length(substring-before($text,' '))"/>
181    <xsl:variable name="after" select="substring-after($text,' ')"/>
182    <xsl:variable name="afterlen" select="string-length($after)"/>
183
184    <xsl:choose>
185      <xsl:when test="number($afterlen)&gt;0">
186        <!--sth behind space-->
187        <xsl:variable name="next-space">
188          <xsl:call-template name="find-last-space">
189            <xsl:with-param name="text" select="$after"/>
190            <xsl:with-param name="len" select="$afterlen"/>
191          </xsl:call-template>
192        </xsl:variable>
193        <xsl:value-of select="number($beforelen)+1+number($next-space)"/>
194      </xsl:when>
195      <xsl:otherwise> <!--$afterlen=0-->
196        <xsl:choose>
197          <xsl:when test="number($beforelen)=0">
198            <!--no spaces found-->
199            <xsl:value-of select="'0'"/>
200          </xsl:when>
201          <xsl:otherwise>
202            <!--space at last position-->
203            <xsl:value-of select="number($beforelen)+1"/>
204          </xsl:otherwise>
205        </xsl:choose>
206      </xsl:otherwise>
207    </xsl:choose>
208  </xsl:template>
209
210  <xsl:template name="indent-preformatted">
211    <xsl:param name="indent" select="''"/>
212    <xsl:param name="text"/>
213    <xsl:param name="prefix" select="''"/>
214
215    <xsl:variable name="indent-length"><xsl:value-of select="string-length($indent) + string-length($prefix)"/></xsl:variable>
216    <xsl:variable name="printlen"><xsl:value-of select="$width - $indent-length"/></xsl:variable>
217    <xsl:variable name="textlen"><xsl:value-of select="string-length($text)"/></xsl:variable>
218
219    <xsl:variable name="line1" select="substring-before($text,$lb)"/>
220    <xsl:variable name="line2" select="substring-after($text,$lb)"/>
221
222    <xsl:choose>
223      <xsl:when test="concat($line1,$line2)=''">
224        <xsl:value-of select="concat($indent,$prefix,$text)"/>
225        <xsl:text>&br;</xsl:text>
226      </xsl:when>
227      <xsl:when test="string-length($line1)=0">
228        <xsl:call-template name="indent-preformatted">
229          <xsl:with-param name="indent" select="$indent"/>
230          <xsl:with-param name="text" select="$line2"/>
231          <xsl:with-param name="prefix" select="$prefix"/>
232        </xsl:call-template>
233      </xsl:when>
234      <xsl:otherwise>
235        <xsl:value-of select="concat($indent,$prefix,$line1)"/>
236        <xsl:text>&br;</xsl:text>
237
238        <xsl:if test="string-length($line2)&gt;0">
239          <xsl:variable name="next-indent">
240            <xsl:choose>
241              <xsl:when test="$prefix=''">
242                <xsl:value-of select="$indent"/>
243              </xsl:when>
244              <xsl:otherwise>
245                <xsl:variable name="enough-spaces">
246                  <xsl:value-of select="$indent"/>
247                  <xsl:text>                    </xsl:text>
248                </xsl:variable>
249                <xsl:value-of select="substring($enough-spaces, 1, $indent-length)"/>
250              </xsl:otherwise>
251            </xsl:choose>
252          </xsl:variable>
253
254          <xsl:call-template name="indent-preformatted">
255            <xsl:with-param name="indent" select="$next-indent"/>
256            <xsl:with-param name="text" select="$line2"/>
257          </xsl:call-template>
258        </xsl:if>
259      </xsl:otherwise>
260    </xsl:choose>
261  </xsl:template>
262
263  <xsl:template name="reflow-paragraph">
264    <xsl:param name="indent" select="''"/>
265    <xsl:param name="text"/>
266    <xsl:param name="prefix" select="''"/>
267
268    <xsl:variable name="indent-length"><xsl:value-of select="string-length($indent) + string-length($prefix)"/></xsl:variable>
269    <xsl:variable name="printlen"><xsl:value-of select="$width - $indent-length"/></xsl:variable>
270    <xsl:variable name="textlen"><xsl:value-of select="string-length($text)"/></xsl:variable>
271
272    <xsl:variable name="this-indent">
273      <xsl:choose>
274        <xsl:when test="$prefix=''">
275          <xsl:value-of select="$indent"/>
276        </xsl:when>
277        <xsl:otherwise>
278          <xsl:value-of select="$indent"/>
279          <xsl:value-of select="$prefix"/>
280        </xsl:otherwise>
281      </xsl:choose>
282    </xsl:variable>
283
284    <xsl:choose>
285      <xsl:when test="number($printlen) &gt;= number($textlen)">
286        <xsl:value-of select="concat($this-indent,$text)"/>
287        <xsl:text>&br;</xsl:text>
288      </xsl:when>
289      <xsl:otherwise>
290        <xsl:variable name="last-space">
291          <xsl:call-template name="find-last-space">
292            <xsl:with-param name="text" select="substring($text,1,$printlen+1)"/>
293            <xsl:with-param name="len" select="$printlen+1"/>
294          </xsl:call-template>
295        </xsl:variable>
296
297        <xsl:variable name="print">
298          <xsl:choose>
299            <xsl:when test="$last-space='0'"><xsl:value-of select="substring($text,1,$printlen)"/></xsl:when>
300            <xsl:otherwise><xsl:value-of select="substring($text,1,$last-space - 1)"/></xsl:otherwise>
301          </xsl:choose>
302        </xsl:variable>
303        <xsl:variable name="rest">
304          <xsl:choose>
305            <xsl:when test="$last-space='0'"><xsl:value-of select="substring($text,$printlen+1)"/></xsl:when>
306            <xsl:otherwise><xsl:value-of select="substring($text,$last-space+1)"/></xsl:otherwise>
307          </xsl:choose>
308        </xsl:variable>
309
310        <xsl:variable name="restlen"><xsl:value-of select="string-length($rest)"/></xsl:variable>
311
312        <xsl:value-of select="concat($this-indent,$print)"/>
313        <xsl:text>&br;</xsl:text>
314
315        <xsl:if test="number($restlen)">
316
317          <xsl:variable name="next-indent">
318            <xsl:choose>
319              <xsl:when test="$prefix=''">
320                <xsl:value-of select="$indent"/>
321              </xsl:when>
322              <xsl:otherwise>
323                <xsl:variable name="enough-spaces">
324                  <xsl:value-of select="$indent"/>
325                  <xsl:text>                    </xsl:text>
326                </xsl:variable>
327                <xsl:value-of select="substring($enough-spaces, 1, $indent-length)"/>
328              </xsl:otherwise>
329            </xsl:choose>
330          </xsl:variable>
331
332          <xsl:call-template name="reflow-paragraph">
333            <xsl:with-param name="indent" select="$next-indent"/>
334            <xsl:with-param name="text" select="$rest"/>
335          </xsl:call-template>
336        </xsl:if>
337      </xsl:otherwise>
338    </xsl:choose>
339  </xsl:template>
340
341  <xsl:template match="ENTRY" mode="calc-prefix">
342    <xsl:choose>
343      <xsl:when test="name(..)='ENUM'">
344        <xsl:value-of select="@enumerated"/>
345        <xsl:text>. </xsl:text>
346      </xsl:when>
347      <xsl:when test="name(..)='LIST'"><xsl:text>* </xsl:text></xsl:when>
348      <xsl:otherwise></xsl:otherwise>
349    </xsl:choose>
350  </xsl:template>
351
352  <xsl:template match="ENUM|LIST" mode="calc-prefix">
353    <xsl:call-template name="error"><xsl:with-param name="text">Illegal ENUM or LIST in calc-prefix-mode</xsl:with-param></xsl:call-template>
354  </xsl:template>
355  <xsl:template match="*|text()" mode="calc-prefix">
356  </xsl:template>
357
358  <xsl:template match="text()" mode="reflow">
359    <xsl:call-template name="error"><xsl:with-param name="text">Illegal text in reflow-mode</xsl:with-param></xsl:call-template>
360  </xsl:template>
361
362  <xsl:template match="text()" mode="preformatted">
363    <xsl:call-template name="error"><xsl:with-param name="text">Illegal text in preformatted-mode</xsl:with-param></xsl:call-template>
364  </xsl:template>
365
366  <xsl:template match="LINK" mode="count-ticket-links">
367    <xsl:if test="@type='ticket'">1</xsl:if>
368  </xsl:template>
369  <xsl:template match="*" mode="count-ticket-links">
370    <xsl:apply-templates mode="count-ticket-links"/>
371  </xsl:template>
372  <xsl:template match="text()" mode="count-ticket-links">
373  </xsl:template>
374
375  <xsl:template match="LINK" mode="expand-links">
376    <xsl:choose>
377      <xsl:when test="@type='hlp' or @type='ps' or @type='pdf'">
378        <xsl:call-template name="link-to-document">
379          <xsl:with-param name="doc" select="@dest"/>
380          <xsl:with-param name="missing" select="@missing"/>
381          <xsl:with-param name="type" select="@type"/>
382        </xsl:call-template>
383      </xsl:when>
384      <xsl:when test="@type='www'">
385        <xsl:call-template name="insert-link">
386          <xsl:with-param name="linktext"><xsl:value-of select="@dest"/></xsl:with-param>
387          <xsl:with-param name="address"><xsl:value-of select="@dest"/></xsl:with-param>
388        </xsl:call-template>
389      </xsl:when>
390      <xsl:when test="@type='ticket'">
391        <xsl:value-of select="@dest"/> <!-- simply insert ticketnumber-->
392      </xsl:when>
393      <xsl:when test="@type='email'">
394        <xsl:call-template name="insert-email-link">
395          <xsl:with-param name="linktext"><xsl:value-of select="@dest"/></xsl:with-param>
396          <xsl:with-param name="address"><xsl:value-of select="@dest"/></xsl:with-param>
397          <xsl:with-param name="subject" select="concat('Concerning helppage ',$myname)"/>
398        </xsl:call-template>
399      </xsl:when>
400      <xsl:otherwise>
401        <xsl:call-template name="error"><xsl:with-param name="text">Unknown link type '<xsl:value-of select="@type"/>'</xsl:with-param></xsl:call-template>
402      </xsl:otherwise>
403    </xsl:choose>
404  </xsl:template>
405
406  <xsl:template match="text()" mode="expand-links">
407    <xsl:value-of select="."/>
408  </xsl:template>
409
410  <xsl:template match="*" mode="expand-links">
411    <xsl:call-template name="error"><xsl:with-param name="text">Illegal content for expand-links</xsl:with-param></xsl:call-template>
412  </xsl:template>
413
414  <xsl:template match="T">
415    <xsl:variable name="indent"><xsl:apply-templates mode="calc-indent" select=".."/></xsl:variable>
416    <xsl:variable name="prefix"><xsl:apply-templates mode="calc-prefix" select=".."/></xsl:variable>
417    <xsl:variable name="text"><xsl:apply-templates mode="expand-links"/></xsl:variable>
418
419    <xsl:choose>
420      <xsl:when test="@reflow='1'">
421        <xsl:call-template name="reflow-paragraph">
422          <xsl:with-param name="indent" select="$indent"/>
423          <xsl:with-param name="text" select="normalize-space($text)"/>
424          <xsl:with-param name="prefix" select="$prefix"/>
425        </xsl:call-template>
426        <xsl:text>&br;</xsl:text>
427      </xsl:when>
428      <xsl:otherwise>
429        <xsl:call-template name="indent-preformatted">
430          <xsl:with-param name="indent" select="$indent"/>
431          <xsl:with-param name="text" select="$text"/>
432          <xsl:with-param name="prefix" select="$prefix"/>
433        </xsl:call-template>
434        <xsl:text>&br;</xsl:text>
435      </xsl:otherwise>
436    </xsl:choose>
437  </xsl:template>
438
439  <xsl:template match="ENTRY"><xsl:apply-templates/></xsl:template>
440
441  <xsl:template match="P"><xsl:apply-templates/></xsl:template>
442
443  <xsl:template match="ENUM"><xsl:apply-templates/></xsl:template>
444  <xsl:template match="LIST"><xsl:apply-templates/></xsl:template>
445
446  <xsl:template match="SECTION" mode="main">
447    <xsl:text>&br;&br;</xsl:text>
448    <xsl:value-of select="@name"/>
449    <xsl:text>&br;&br;</xsl:text>
450    <xsl:apply-templates/>
451  </xsl:template>
452
453  <!-- ================================ -->
454  <!--     PAGE document wide layout    -->
455  <!-- ================================ -->
456
457  <!-- ============================== -->
458  <!--     insert document header     -->
459  <!-- ============================== -->
460  <xsl:template name="header">
461    <xsl:param name="title" select="'Untitled'"/>
462    <xsl:param name="for"/>
463    <xsl:text xml:space="preserve"># Generated from XML with xsltproc -- Stylesheet by Ralf Westram (ralf@arb-home.de)</xsl:text>
464    <xsl:choose>
465      <xsl:when test="$for='release'">
466        <!-- this section and ... -->
467        <xsl:text xml:space="preserve">
468#  ****  You may edit this file, but the next ARB update will overwrite your changes  ****
469#  ****  When editing from inside ARB, your changes will be archived. Feel free to send these to us. ****
470</xsl:text>
471      </xsl:when>
472      <xsl:when test="$for='devel'">
473        <!-- ... this section HAVE TO generate the same amount of output-lines! -->
474        <!-- OTHERWISE unit tests will fail! -->
475        <xsl:text xml:space="preserve">
476#
477#  ****  DO NOT EDIT (edit in $(ARBHOME)/HELP_SOURCE/source instead)  ****
478</xsl:text>
479      </xsl:when>
480      <xsl:otherwise>
481        <xsl:call-template name="error"><xsl:with-param name="text">Illegal content in edit_warning</xsl:with-param></xsl:call-template>
482      </xsl:otherwise>
483    </xsl:choose>
484  </xsl:template>
485
486  <xsl:template match="PAGE">
487      <xsl:variable name="title">
488        <xsl:for-each select="TITLE"><xsl:value-of select="text()"/></xsl:for-each>
489      </xsl:variable>
490      <xsl:variable name="subtitle">
491        <xsl:for-each select="SUBTITLE"><xsl:value-of select="text()"/></xsl:for-each>
492      </xsl:variable>
493      <xsl:variable name="bugsTracked"><xsl:apply-templates mode="count-ticket-links"/></xsl:variable>
494      <xsl:call-template name="header">
495        <xsl:with-param name="title" select="$title"/>
496        <xsl:with-param name="for" select="@edit_warning"/>
497      </xsl:call-template>#
498# This page was converted by arb_help2xml and may look strange.
499# If you think it's really bad, please send a
500# <xsl:call-template name="insert-email-link">
501        <xsl:with-param name="linktext">mail</xsl:with-param>
502        <xsl:with-param name="address">helpfeedback</xsl:with-param>
503        <xsl:with-param name="subject" select="concat('Helppage ',$myname,' looks weird')"/>
504      </xsl:call-template>
505# to our help keeper.
506
507# UP references:
508<xsl:apply-templates mode="uplinks"/>
509# SUB references:
510<xsl:apply-templates mode="sublinks"/>
511<xsl:if test="string-length($bugsTracked) &gt; 0">
512  <!-- insert link to page describing arb-bugtracker -->
513  <xsl:call-template name="insert-topic">
514    <xsl:with-param name="type" select="'SUB'"/>
515    <xsl:with-param name="dest" select="'bugtracker.hlp'"/>
516  </xsl:call-template>
517</xsl:if>
518# ------------------------------------------------------------
519# Start of real helpfile:
520TITLE&tab;<xsl:value-of select="normalize-space($title)"/>
521<xsl:if test="string-length($subtitle) &gt; 0">
522  <xsl:text>&br;</xsl:text>
523  <xsl:text>&br;    </xsl:text><xsl:value-of select="normalize-space($subtitle)"/>
524</xsl:if>
525<xsl:apply-templates select="SECTION" mode="main"/>
526  </xsl:template>
527
528  <!-- ============ -->
529  <!--     text()   (should be last template)  -->
530  <!-- ============ -->
531  <xsl:template match="text()|*">
532   <xsl:choose>
533     <xsl:when test="string-length(name())>0">
534       <xsl:call-template name="error"><xsl:with-param name="text">Unknown TAG <xsl:value-of select="name()"/></xsl:with-param></xsl:call-template>
535      </xsl:when>
536      <xsl:otherwise>
537<!--        <xsl:value-of select="."/>-->
538<!--        <xsl:call-template name="error"><xsl:with-param name="text">Unexpected text</xsl:with-param></xsl:call-template>-->
539      </xsl:otherwise>
540    </xsl:choose>
541  </xsl:template>
542
543
544</xsl:transform>
545
Note: See TracBrowser for help on using the repository browser.