~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/erl_docgen/priv/xsl/db_pdf.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?xml version="1.0" encoding="utf-8"?>
2
 
<!--      
 
2
<!--
3
3
     #
4
4
     # %CopyrightBegin%
5
 
     # 
6
 
     # Copyright Ericsson AB 2009. All Rights Reserved.
7
 
     # 
 
5
     #
 
6
     # Copyright Ericsson AB 2009-2011. All Rights Reserved.
 
7
     #
8
8
     # The contents of this file are subject to the Erlang Public License,
9
9
     # Version 1.1, (the "License"); you may not use this file except in
10
10
     # compliance with the License. You should have received a copy of the
11
11
     # Erlang Public License along with this software. If not, it can be
12
12
     # retrieved online at http://www.erlang.org/.
13
 
     # 
 
13
     #
14
14
     # Software distributed under the License is distributed on an "AS IS"
15
15
     # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16
16
     # the License for the specific language governing rights and limitations
17
17
     # under the License.
18
 
     # 
 
18
     #
19
19
     # %CopyrightEnd%
20
 
     
 
20
 
21
21
     -->
22
22
<xsl:stylesheet version="1.0"
23
23
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27
27
 
28
28
  <xsl:include href="db_pdf_params.xsl"/>
29
29
 
 
30
  <!-- Start of Dialyzer type/spec tags.
 
31
       See also the template matching "name" and the template "bookmarks6"
 
32
  -->
 
33
 
 
34
  <xsl:param name="specs_file" select="''"/>
 
35
  <xsl:variable name="i" select="document($specs_file)"></xsl:variable>
 
36
 
 
37
  <xsl:template name="err">
 
38
    <xsl:param name="m"/>
 
39
    <xsl:param name="n"/>
 
40
    <xsl:param name="a"/>
 
41
    <xsl:param name="s"/>
 
42
    <xsl:message terminate="yes">
 
43
  Error <xsl:if test="$m != ''"><xsl:value-of select ="$m"/>:</xsl:if>
 
44
         <xsl:value-of
 
45
                   select="$n"/>/<xsl:value-of
 
46
                   select="$a"/>: <xsl:value-of select="$s"/>
 
47
    </xsl:message>
 
48
  </xsl:template>
 
49
 
 
50
  <xsl:template name="spec_name">
 
51
    <xsl:variable name="curModule" select="ancestor::erlref/module"/>
 
52
    <xsl:variable name="mod" select="@mod"/>
 
53
    <xsl:variable name="name" select="@name"/>
 
54
    <xsl:variable name="arity" select="@arity"/>
 
55
    <xsl:variable name="clause" select="@clause"/>
 
56
    <xsl:variable name="spec0" select=
 
57
        "$i/specs/module[@name=$curModule]/spec
 
58
             [name=$name and arity=$arity
 
59
              and (string-length($mod) = 0 or module = $mod)]"/>
 
60
    <xsl:variable name="spec" select="$spec0[string-length($clause) = 0
 
61
                                             or position() = $clause]"/>
 
62
    <xsl:if test="count($spec) = 0">
 
63
      <xsl:call-template name="err">
 
64
        <xsl:with-param name="m" select="$mod"/>
 
65
        <xsl:with-param name="n" select="$name"/>
 
66
        <xsl:with-param name="a" select="$arity"/>
 
67
        <xsl:with-param name="s">unknown spec</xsl:with-param>
 
68
      </xsl:call-template>
 
69
    </xsl:if>
 
70
 
 
71
    <xsl:choose>
 
72
      <xsl:when test="ancestor::cref">
 
73
        <xsl:message terminate="yes">
 
74
          Error: did not expect a 'name' tag with name/arity attributes here!
 
75
        </xsl:message>
 
76
      </xsl:when>
 
77
      <xsl:when test="ancestor::erlref">
 
78
        <fo:block id="{generate-id()}">
 
79
          <xsl:choose>
 
80
            <xsl:when test="string(@with_guards) = 'no'">
 
81
               <xsl:apply-templates select="$spec/contract/clause/head"/>
 
82
            </xsl:when>
 
83
            <xsl:otherwise>
 
84
              <xsl:call-template name="contract">
 
85
                <xsl:with-param name="contract" select="$spec/contract"/>
 
86
              </xsl:call-template>
 
87
            </xsl:otherwise>
 
88
          </xsl:choose>
 
89
        </fo:block>
 
90
      </xsl:when>
 
91
    </xsl:choose>
 
92
  </xsl:template>
 
93
 
 
94
  <xsl:template name="contract">
 
95
    <xsl:param name="contract"/>
 
96
    <xsl:call-template name="clause">
 
97
      <xsl:with-param name="clause" select="$contract/clause"/>
 
98
    </xsl:call-template>
 
99
  </xsl:template>
 
100
 
 
101
  <xsl:template name="clause">
 
102
    <xsl:param name="clause"/>
 
103
    <xsl:variable name="type_desc" select="../type_desc"/>
 
104
    <xsl:for-each select="$clause">
 
105
      <xsl:apply-templates select="head"/>
 
106
      <xsl:if test="count(guard) > 0">
 
107
        <xsl:call-template name="guard">
 
108
          <xsl:with-param name="guard" select="guard"/>
 
109
          <xsl:with-param name="type_desc" select="$type_desc"/>
 
110
        </xsl:call-template>
 
111
      </xsl:if>
 
112
    </xsl:for-each>
 
113
  </xsl:template>
 
114
 
 
115
  <xsl:template match="head">
 
116
    <fo:block xsl:use-attribute-sets="function-name">
 
117
      <xsl:apply-templates/>
 
118
    </fo:block>
 
119
  </xsl:template>
 
120
 
 
121
  <xsl:template name="guard">
 
122
    <fo:block>
 
123
      <xsl:text>Types:</xsl:text>
 
124
    </fo:block>
 
125
    <fo:list-block xsl:use-attribute-sets="type-listblock">
 
126
      <xsl:call-template name="subtype">
 
127
        <xsl:with-param name="subtype" select="$guard/subtype"/>
 
128
        <xsl:with-param name="type_desc" select="$type_desc"/>
 
129
      </xsl:call-template>
 
130
    </fo:list-block>
 
131
  </xsl:template>
 
132
 
 
133
  <xsl:template name="subtype">
 
134
    <xsl:param name="subtype"/>
 
135
    <xsl:param name="type_desc"/>
 
136
    <xsl:for-each select="$subtype">
 
137
      <xsl:variable name="tname" select="typename"/>
 
138
      <xsl:variable name="tdesc" select="$type_desc[@name = $tname]"/>
 
139
      <fo:list-item xsl:use-attribute-sets="type-listitem">
 
140
        <fo:list-item-label end-indent="label-end()">
 
141
          <fo:block>
 
142
          </fo:block>
 
143
        </fo:list-item-label>
 
144
        <fo:list-item-body start-indent="body-start()" format="justify">
 
145
          <fo:block font-weight="bold">
 
146
            <xsl:apply-templates select="string"/>
 
147
          </fo:block>
 
148
        </fo:list-item-body>
 
149
      </fo:list-item>
 
150
      <xsl:apply-templates select="$type_desc[@name = $tname]"/>
 
151
    </xsl:for-each>
 
152
  </xsl:template>
 
153
 
 
154
  <!-- Note: <type_desc> has not been implemented for data types. -->
 
155
 
 
156
  <!-- Similar to <d> -->
 
157
  <xsl:template match="type_desc">
 
158
    <fo:list-item xsl:use-attribute-sets="type-listitem">
 
159
      <fo:list-item-label end-indent="label-end()"><fo:block></fo:block>
 
160
      </fo:list-item-label>
 
161
      <fo:list-item-body start-indent="body-start()" format="justify">
 
162
        <fo:block>
 
163
          <xsl:apply-templates/>
 
164
        </fo:block>
 
165
      </fo:list-item-body>
 
166
    </fo:list-item>
 
167
  </xsl:template>
 
168
 
 
169
  <!-- Datatypes -->
 
170
  <xsl:template match="datatypes">
 
171
    <fo:block  xsl:use-attribute-sets="h3">
 
172
      <xsl:text>Data Types</xsl:text>
 
173
    </fo:block>
 
174
    <xsl:apply-templates/>
 
175
  </xsl:template>
 
176
 
 
177
  <!-- Datatype -->
 
178
  <xsl:template match="datatype">
 
179
    <fo:block xsl:use-attribute-sets="function-name">
 
180
      <xsl:apply-templates select="name"/>
 
181
    </fo:block>
 
182
    <xsl:apply-templates select="desc"/>
 
183
  </xsl:template>
 
184
 
 
185
  <!-- Like <head>... -->
 
186
  <xsl:template match="typehead">
 
187
    <fo:block xsl:use-attribute-sets="function-name">
 
188
      <xsl:apply-templates/>
 
189
    </fo:block>
 
190
  </xsl:template>
 
191
 
 
192
  <!-- Like <guard>, except "Types:"... -->
 
193
  <xsl:template match="local_defs">
 
194
    <fo:list-block xsl:use-attribute-sets="type-listblock">
 
195
      <xsl:apply-templates/>
 
196
    </fo:list-block>
 
197
  </xsl:template>
 
198
 
 
199
  <!-- Like <subtype>... -->
 
200
  <xsl:template match="local_def">
 
201
    <fo:list-item xsl:use-attribute-sets="type-listitem">
 
202
      <fo:list-item-label end-indent="label-end()">
 
203
        <fo:block>
 
204
        </fo:block>
 
205
      </fo:list-item-label>
 
206
      <fo:list-item-body start-indent="body-start()" format="justify">
 
207
        <fo:block font-weight="bold">
 
208
          <xsl:apply-templates/>
 
209
        </fo:block>
 
210
      </fo:list-item-body>
 
211
    </fo:list-item>
 
212
  </xsl:template>
 
213
 
 
214
  <xsl:template name="type_name">
 
215
    <xsl:variable name="curModule" select="ancestor::erlref/module"/>
 
216
    <xsl:variable name="mod" select="@mod"/>
 
217
    <xsl:variable name="name" select="@name"/>
 
218
    <xsl:variable name="n_vars">
 
219
      <xsl:choose>
 
220
        <xsl:when test="string-length(@n_vars) > 0">
 
221
          <xsl:value-of select="@n_vars"/>
 
222
        </xsl:when>
 
223
        <xsl:otherwise>
 
224
          <xsl:value-of select="0"/>
 
225
        </xsl:otherwise>
 
226
      </xsl:choose>
 
227
    </xsl:variable>
 
228
 
 
229
    <xsl:choose>
 
230
      <xsl:when test="string-length($name) > 0">
 
231
        <xsl:variable name="type" select=
 
232
            "$i/specs/module[@name=$curModule]/type
 
233
                 [name=$name and n_vars=$n_vars
 
234
                  and (string-length($mod) = 0 or module = $mod)]"/>
 
235
 
 
236
        <xsl:if test="count($type) != 1">
 
237
          <xsl:call-template name="err">
 
238
            <xsl:with-param name="m" select="$mod"/>
 
239
            <xsl:with-param name="n" select="$name"/>
 
240
            <xsl:with-param name="a" select="$n_vars"/>
 
241
            <xsl:with-param name="s">unknown type</xsl:with-param>
 
242
          </xsl:call-template>
 
243
        </xsl:if>
 
244
        <xsl:apply-templates select="$type/typedecl"/>
 
245
      </xsl:when>
 
246
      <xsl:otherwise>
 
247
        <fo:inline font-weight="bold" xsl:use-attribute-sets="type-listitem">
 
248
        <xsl:value-of select="."/>
 
249
        </fo:inline>
 
250
      </xsl:otherwise>
 
251
    </xsl:choose>
 
252
  </xsl:template>
 
253
 
 
254
  <!-- Used both in <datatype> and in <func>! -->
 
255
  <xsl:template match="anno">
 
256
    <xsl:variable name="curModule" select="ancestor::erlref/module"/>
 
257
    <xsl:variable name="anno" select="normalize-space(text())"/>
 
258
    <xsl:variable name="namespec"
 
259
                  select="ancestor::desc/preceding-sibling::name"/>
 
260
    <xsl:if test="count($namespec) = 0 and string-length($specs_file) > 0">
 
261
      <xsl:call-template name="err">
 
262
        <xsl:with-param name="s">cannot find 'name' (<xsl:value-of select="$anno"/>)
 
263
        </xsl:with-param>
 
264
      </xsl:call-template>
 
265
    </xsl:if>
 
266
 
 
267
    <xsl:variable name="mod" select="$namespec/@mod"/>
 
268
    <xsl:variable name="name" select="$namespec/@name"/>
 
269
    <xsl:variable name="arity" select="$namespec/@arity"/>
 
270
    <xsl:variable name="clause" select="$namespec/@clause"/>
 
271
    <xsl:variable name="tmp_n_vars" select="$namespec/@n_vars"/>
 
272
    <xsl:variable name="n_vars">
 
273
      <xsl:choose>
 
274
        <xsl:when test="string-length($tmp_n_vars) > 0">
 
275
          <xsl:value-of select="$tmp_n_vars"/>
 
276
        </xsl:when>
 
277
        <xsl:otherwise>
 
278
          <xsl:value-of select="0"/>
 
279
        </xsl:otherwise>
 
280
      </xsl:choose>
 
281
    </xsl:variable>
 
282
    <xsl:variable name="spec0" select=
 
283
        "$i/specs/module[@name=$curModule]/spec
 
284
             [name=$name and arity=$arity
 
285
              and (string-length($mod) = 0 or module = $mod)]"/>
 
286
    <xsl:variable name="spec_annos" select=
 
287
         "$spec0[string-length($clause) = 0
 
288
                 or position() = $clause]/anno[.=$anno]"/>
 
289
    <xsl:variable name="type_annos" select=
 
290
        "$i/specs/module[@name=$curModule]/type
 
291
             [name=$name and n_vars=$n_vars
 
292
              and (string-length($mod) = 0 or module = $mod)]/anno[.=$anno]"/>
 
293
 
 
294
    <xsl:if test="count($spec_annos) = 0
 
295
                  and count($type_annos) = 0
 
296
                  and string-length($specs_file) > 0">
 
297
      <xsl:variable name="n">
 
298
        <xsl:choose>
 
299
          <xsl:when test="string-length($arity) = 0">
 
300
            <xsl:value-of select="$n_vars"/>
 
301
          </xsl:when>
 
302
          <xsl:otherwise>
 
303
            <xsl:value-of select="$arity"/>
 
304
          </xsl:otherwise>
 
305
        </xsl:choose>
 
306
      </xsl:variable>
 
307
      <xsl:call-template name="err">
 
308
        <xsl:with-param name="m" select="$mod"/>
 
309
        <xsl:with-param name="n" select="$name"/>
 
310
        <xsl:with-param name="a" select="$n"/>
 
311
        <xsl:with-param name="s">unknown annotation <xsl:value-of select="$anno"/>
 
312
        </xsl:with-param>
 
313
      </xsl:call-template>
 
314
    </xsl:if>
 
315
    <xsl:value-of select="$anno"/>
 
316
  </xsl:template>
 
317
 
 
318
  <!-- Used for indentation of formatted types and specs -->
 
319
  <xsl:template match="nbsp">
 
320
    <xsl:text>&#160;</xsl:text>
 
321
  </xsl:template>
 
322
 
 
323
  <!-- End of Dialyzer type/spec tags -->
30
324
 
31
325
  <xsl:template match="/">
32
326
    <xsl:apply-templates select="book"/>
33
327
  </xsl:template>
34
328
 
35
 
  
 
329
 
36
330
  <xsl:template match="book">
37
331
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
38
332
 
39
 
      <!-- Master pages -->          
 
333
      <!-- Master pages -->
40
334
      <fo:layout-master-set>
41
335
        <fo:simple-page-master
42
336
            master-name="cover"
47
341
          <xsl:attribute name="page-width">
48
342
            <xsl:value-of select="$page-width"/>
49
343
          </xsl:attribute>
50
 
          <fo:region-body 
 
344
          <fo:region-body
51
345
              margin="0mm"/>
52
346
        </fo:simple-page-master>
53
347
 
63
357
          <xsl:attribute name="page-width">
64
358
            <xsl:value-of select="$page-width"/>
65
359
          </xsl:attribute>
66
 
          <fo:region-body 
 
360
          <fo:region-body
67
361
              margin-top="15mm"
68
362
              margin-bottom="20mm"/>
69
363
          <fo:region-before
100
394
 
101
395
        <fo:page-sequence-master master-name="document">
102
396
          <fo:repeatable-page-master-alternatives>
103
 
            <fo:conditional-page-master-reference 
 
397
            <fo:conditional-page-master-reference
104
398
                master-reference="left-page"
105
399
                odd-or-even="even"/>
106
 
            <fo:conditional-page-master-reference 
 
400
            <fo:conditional-page-master-reference
107
401
                master-reference="right-page"
108
402
                odd-or-even="odd"/>
109
403
          </fo:repeatable-page-master-alternatives>
166
460
 
167
461
        <fo:flow flow-name="xsl-region-body">
168
462
          <fo:block>
169
 
            
 
463
 
170
464
          </fo:block>
171
465
          <xsl:apply-templates select="parts"/>
172
466
 
189
483
 
190
484
  <!-- Cover page -->
191
485
  <xsl:template match="header/title">
192
 
    <fo:page-sequence 
 
486
    <fo:page-sequence
193
487
        font-family="sans-serif"
194
488
        force-page-count="even"
195
489
        master-reference="cover">
229
523
          <xsl:value-of select="$companyname"/>
230
524
        </fo:block>
231
525
        <fo:block xsl:use-attribute-sets="cover.inner.copyrightnotice">
232
 
  The contents of this file are subject to the Erlang Public License,
 
526
          <xsl:value-of select="/book/header/legalnotice"/>
 
527
 
 
528
        <!--   The contents of this file are subject to the Erlang Public License,
233
529
  Version 1.1, (the "License"); you may not use this file except in
234
530
  compliance with the License. You should have received a copy of the
235
531
  Erlang Public License along with this software. If not, it can be
240
536
  the License for the specific language governing rights and limitations
241
537
  under the License.
242
538
 
243
 
  The Initial Developer of the Original Code is 
 
539
  The Initial Developer of the Original Code is
 
540
-->
244
541
          <xsl:value-of select="$companyname"/>.
245
542
        </fo:block>
246
543
        <fo:block xsl:use-attribute-sets="cover.inner.date">
278
575
  <xsl:template name="bookmarks1">
279
576
    <xsl:param name="entries"/>
280
577
    <xsl:if test="$entries != ''">
281
 
      
 
578
 
282
579
      <fo:bookmark internal-destination="{generate-id(/book/parts/part)}"
283
580
        starting-state="hide">
284
581
        <fo:bookmark-title>User's Guide</fo:bookmark-title>
285
 
        
 
582
 
286
583
        <xsl:for-each select="$entries">
287
584
          <xsl:call-template name="bookmarks2">
288
585
            <xsl:with-param name="entries"
289
586
              select="chapter[header/title]"/>
290
587
          </xsl:call-template>
291
588
        </xsl:for-each>
292
 
        
 
589
 
293
590
      </fo:bookmark>
294
591
    </xsl:if>
295
592
  </xsl:template>
296
 
  
 
593
 
297
594
  <xsl:template name="bookmarks2">
298
595
    <xsl:param name="entries"/>
299
596
    <xsl:for-each select="$entries">
338
635
        starting-state="hide">
339
636
        <fo:bookmark-title>Reference Manual</fo:bookmark-title>
340
637
        <xsl:for-each select="$entries">
341
 
          
 
638
 
342
639
          <xsl:call-template name="bookmarks5">
343
640
            <xsl:with-param name="entries"
344
641
              select="erlref[module]|comref[com]|cref[lib]|fileref[file]|appref[app]"/>
382
679
      <xsl:choose>
383
680
        <xsl:when test="ancestor::cref">
384
681
          <fo:bookmark internal-destination="{generate-id(nametext)}" starting-state="hide">
385
 
            <xsl:variable name="fname"><xsl:value-of select="substring-before(nametext, '(')"/></xsl:variable> 
 
682
            <xsl:variable name="fname">
 
683
              <xsl:value-of select="substring-before(nametext, '(')"/>
 
684
            </xsl:variable>
386
685
            <fo:bookmark-title>
387
686
              <xsl:choose>
388
687
                <xsl:when test="string-length($fname) > 0">
391
690
                <xsl:otherwise>
392
691
                  <xsl:value-of select="nametext"/>()
393
692
                </xsl:otherwise>
394
 
              </xsl:choose>                 
 
693
              </xsl:choose>
395
694
            </fo:bookmark-title>
396
695
          </fo:bookmark>
397
696
        </xsl:when>
399
698
          <fo:bookmark internal-destination="{generate-id(.)}" starting-state="hide">
400
699
            <xsl:variable name="tmpstring">
401
700
              <xsl:value-of select="substring-before(substring-after(., '('), '->')"/>
402
 
            </xsl:variable>     
 
701
            </xsl:variable>
403
702
 
404
703
            <xsl:variable name="ustring">
405
704
              <xsl:choose>
406
705
                <xsl:when test="string-length($tmpstring) > 0">
407
706
                  <xsl:call-template name="remove-paren">
408
707
                    <xsl:with-param name="string" select="$tmpstring"/>
409
 
                  </xsl:call-template>            
 
708
                  </xsl:call-template>
410
709
                </xsl:when>
411
710
                <xsl:otherwise>
412
711
                  <xsl:call-template name="remove-paren">
413
712
                    <xsl:with-param name="string" select="substring-after(., '(')"/>
414
 
                  </xsl:call-template>                      
 
713
                  </xsl:call-template>
415
714
                </xsl:otherwise>
416
715
              </xsl:choose>
417
 
            </xsl:variable>      
 
716
            </xsl:variable>
418
717
 
419
718
            <xsl:variable name="arity">
420
 
              <xsl:call-template name="calc-arity">
421
 
                <xsl:with-param name="string" select="substring-before($ustring, ')')"/>
422
 
                <xsl:with-param name="no-of-pars" select="0"/> 
423
 
              </xsl:call-template>
424
 
            </xsl:variable> 
 
719
              <xsl:choose>
 
720
                <xsl:when test="string-length(@arity) > 0">
 
721
                  <!-- Dialyzer spec -->
 
722
                  <xsl:value-of select="@arity"/>
 
723
                </xsl:when>
 
724
                <xsl:otherwise>
 
725
                  <xsl:call-template name="calc-arity">
 
726
                    <xsl:with-param name="string" select="substring-before($ustring, ')')"/>
 
727
                    <xsl:with-param name="no-of-pars" select="0"/>
 
728
                  </xsl:call-template>
 
729
                </xsl:otherwise>
 
730
              </xsl:choose>
 
731
            </xsl:variable>
 
732
 
 
733
            <xsl:variable name="fname">
 
734
              <xsl:choose>
 
735
                <xsl:when test="string-length(@name) > 0">
 
736
                  <!-- Dialyzer spec -->
 
737
                  <xsl:value-of select="@name"/>
 
738
                </xsl:when>
 
739
                <xsl:otherwise>
 
740
                  <xsl:variable name="fname1">
 
741
                    <xsl:value-of select="substring-before(., '(')"/>
 
742
                  </xsl:variable>
 
743
                  <xsl:variable name="fname2">
 
744
                    <xsl:value-of select="substring-after($fname1, 'erlang:')"/>
 
745
                  </xsl:variable>
 
746
                  <xsl:choose>
 
747
                    <xsl:when test="string-length($fname2) > 0">
 
748
                      <xsl:value-of select="$fname2"/>
 
749
                    </xsl:when>
 
750
                    <xsl:otherwise>
 
751
                      <xsl:value-of select="$fname1"/>
 
752
                    </xsl:otherwise>
 
753
                  </xsl:choose>
 
754
                </xsl:otherwise>
 
755
              </xsl:choose>
 
756
            </xsl:variable>
 
757
 
425
758
            <fo:bookmark-title>
426
 
              <xsl:value-of select="substring-before(., '(')"/>/<xsl:value-of select="$arity"/>
 
759
              <xsl:value-of select="$fname"/>/<xsl:value-of select="$arity"/>
427
760
            </fo:bookmark-title>
428
761
          </fo:bookmark>
429
762
        </xsl:when>
430
763
      </xsl:choose>
431
 
      
 
764
 
432
765
    </xsl:for-each>
433
766
  </xsl:template>
434
767
 
435
768
 
436
769
  <!-- UG part -->
437
 
  
 
770
 
438
771
  <!-- Parts -->
439
772
  <xsl:template match="parts">
440
773
    <xsl:apply-templates select="part"/>
468
801
        <xsl:value-of select="$partnum"/>.<xsl:number/>&#160;&#160;<xsl:value-of select="header/title"/>
469
802
      </fo:marker>
470
803
      <xsl:value-of select="$partnum"/>.<xsl:number/>&#160;&#160;<xsl:value-of select="header/title"/>
471
 
      
 
804
 
472
805
    </fo:block>
473
806
 
474
807
    <xsl:apply-templates select="section|quote|warning|note|br|image|marker|table|p|pre|code|list|taglist|codeinclude|erleval">
494
827
 
495
828
  </xsl:template>
496
829
 
497
 
  <!--  Chapter/Subsection -->
 
830
  <!--  Chapter/Subsection  -->
498
831
  <xsl:template match="chapter/section/section">
499
832
    <xsl:param name="partnum"/>
500
833
    <xsl:param name="chapnum"/>
511
844
  </xsl:template>
512
845
 
513
846
 
 
847
  <!--  Subsection below level 2 -->
 
848
  <xsl:template match="section/section/section">
 
849
    <xsl:param name="partnum"/>
 
850
    <xsl:param name="chapnum"/>
 
851
    <xsl:param name="sectnum"/>
 
852
    <fo:block xsl:use-attribute-sets="h5" id="{generate-id(title)}">
 
853
      <!-- xsl:value-of select="$partnum"/>.<xsl:value-of select="$chapnum"/>.<xsl:value-of select="$sectnum"/>.<xsl:number/ -->
 
854
      <xsl:value-of select="title"/>
 
855
    </fo:block>
 
856
    <xsl:apply-templates>
 
857
      <xsl:with-param name="partnum" select="$partnum"/>
 
858
      <xsl:with-param name="chapnum" select="$chapnum"/>
 
859
      <xsl:with-param name="sectnum" select="$sectnum"/>
 
860
    </xsl:apply-templates>
 
861
  </xsl:template>
 
862
 
514
863
 
515
864
  <!-- *ref/Section -->
516
865
  <xsl:template match="erlref/section|comref/section|cref/section|fileref/section|appref/section">
544
893
 </xsl:template>
545
894
 
546
895
  <!-- Lists -->
547
 
  
 
896
 
548
897
  <xsl:template match="list">
549
898
    <xsl:param name="partnum"/>
550
899
    <fo:list-block xsl:use-attribute-sets="listblock">
668
1017
      <xsl:number level="any" from="part" count="code"/>
669
1018
    </xsl:variable>
670
1019
 
671
 
    <fo:block xsl:use-attribute-sets="code" margin-left="1.5em">
672
 
      <xsl:apply-templates select="text()"/> 
 
1020
    <fo:block xsl:use-attribute-sets="code">
 
1021
      <xsl:apply-templates select="text()"/>
673
1022
    </fo:block>
674
1023
 
675
1024
    <xsl:if test="@caption">
676
 
      <fo:block xsl:use-attribute-sets="caption" margin-left="1.5em">
 
1025
      <fo:block xsl:use-attribute-sets="caption">
677
1026
          Code listing <xsl:value-of select="$partnum"/>.<xsl:value-of select="$codenum"/>:&#160;
678
1027
          <xsl:value-of select="@caption"/>
679
1028
      </fo:block>
687
1036
      <xsl:number level="any" from="part" count="code"/>
688
1037
    </xsl:variable>
689
1038
 
690
 
    <fo:block xsl:use-attribute-sets="code" margin-left="1.5em">
691
 
      <xsl:apply-templates/> 
 
1039
    <fo:block xsl:use-attribute-sets="code">
 
1040
      <xsl:apply-templates/>
692
1041
    </fo:block>
693
1042
 
694
1043
    <xsl:if test="@caption">
695
 
      <fo:block xsl:use-attribute-sets="caption" margin-left="1.5em">
 
1044
      <fo:block xsl:use-attribute-sets="caption">
696
1045
          Code listing <xsl:value-of select="$partnum"/>.<xsl:value-of select="$codenum"/>:&#160;
697
1046
          <xsl:value-of select="@caption"/>
698
1047
      </fo:block>
711
1060
    <xsl:variable name="partnum">
712
1061
      <xsl:number level="any" from="book" count="part|application"/>
713
1062
    </xsl:variable>
714
 
    
715
 
    <fo:block xsl:use-attribute-sets="h1" id="{generate-id()}">         
 
1063
 
 
1064
    <fo:block xsl:use-attribute-sets="h1" id="{generate-id()}">
716
1065
      <xsl:if test="/book/header/title">
717
1066
        <xsl:value-of select="$partnum"/>&#160;&#160;&#160;
718
1067
      <xsl:text>Reference Manual</xsl:text>
719
 
      </xsl:if>          
 
1068
      </xsl:if>
720
1069
    </fo:block>
721
 
    
722
 
    
 
1070
 
 
1071
 
723
1072
    <xsl:apply-templates select="description">
724
1073
      <xsl:with-param name="partnum" select="$partnum"/>
725
1074
    </xsl:apply-templates>
726
 
    
 
1075
 
727
1076
    <xsl:apply-templates select="erlref|comref|cref|fileref|appref">
728
1077
      <xsl:with-param name="partnum" select="$partnum"/>
729
1078
    </xsl:apply-templates>
730
 
    
 
1079
 
731
1080
  </xsl:template>
732
1081
 
733
1082
  <!-- Erlref -->
740
1089
        <fo:marker marker-class-name="chapter-title">
741
1090
          <xsl:value-of select="module"/>
742
1091
        </fo:marker>
743
 
        <xsl:value-of select="module"/>                  
 
1092
        <xsl:value-of select="module"/>
744
1093
      </fo:block>
745
1094
      <xsl:text>Erlang module</xsl:text>
746
1095
    </fo:block>
761
1110
        <fo:marker marker-class-name="chapter-title">
762
1111
          <xsl:value-of select="com"/>
763
1112
        </fo:marker>
764
 
        <xsl:value-of select="com"/>                  
 
1113
        <xsl:value-of select="com"/>
765
1114
      </fo:block>
766
1115
      <xsl:text>Command</xsl:text>
767
1116
    </fo:block>
782
1131
        <fo:marker marker-class-name="chapter-title">
783
1132
          <xsl:value-of select="lib"/>
784
1133
        </fo:marker>
785
 
        <xsl:value-of select="lib"/>                  
 
1134
        <xsl:value-of select="lib"/>
786
1135
      </fo:block>
787
1136
      <xsl:text>C Library</xsl:text>
788
1137
    </fo:block>
803
1152
        <fo:marker marker-class-name="chapter-title">
804
1153
          <xsl:value-of select="file"/>
805
1154
        </fo:marker>
806
 
        <xsl:value-of select="file"/>                  
 
1155
        <xsl:value-of select="file"/>
807
1156
      </fo:block>
808
1157
      <xsl:text>Name</xsl:text>
809
1158
    </fo:block>
824
1173
        <fo:marker marker-class-name="chapter-title">
825
1174
          <xsl:value-of select="app"/>
826
1175
        </fo:marker>
827
 
        <xsl:value-of select="app"/>                  
 
1176
        <xsl:value-of select="app"/>
828
1177
      </fo:block>
829
1178
      <xsl:text>Application</xsl:text>
830
1179
    </fo:block>
862
1211
 
863
1212
  <!-- Funcs -->
864
1213
  <xsl:template match="funcs">
865
 
 
 
1214
    <xsl:param name="partnum"/>
866
1215
    <fo:block  xsl:use-attribute-sets="h3">
867
1216
      <xsl:text>Exports</xsl:text>
868
1217
    </fo:block>
877
1226
  <xsl:template match="func">
878
1227
    <xsl:param name="partnum"/>
879
1228
 
880
 
    <fo:block xsl:use-attribute-sets="function-name">
881
 
      <xsl:apply-templates select="name"/>
882
 
    </fo:block>
 
1229
    <xsl:apply-templates select="name"/>
883
1230
 
884
1231
    <xsl:apply-templates select="fsummary|type|desc">
885
1232
      <xsl:with-param name="partnum" select="$partnum"/>
891
1238
  <xsl:template match="name">
892
1239
    <xsl:param name="partnum"/>
893
1240
    <xsl:choose>
 
1241
      <!-- @arity is mandatory when referring to a specification -->
 
1242
      <xsl:when test="string-length(@arity) > 0">
 
1243
        <xsl:call-template name="spec_name"/>
 
1244
      </xsl:when>
 
1245
      <xsl:when test="ancestor::datatype">
 
1246
        <xsl:call-template name="type_name"/>
 
1247
      </xsl:when>
 
1248
      <xsl:otherwise>
 
1249
        <fo:block xsl:use-attribute-sets="function-name">
 
1250
          <xsl:call-template name="name">
 
1251
            <xsl:with-param name="partnum" select="$partnum"/>
 
1252
          </xsl:call-template>
 
1253
        </fo:block>
 
1254
      </xsl:otherwise>
 
1255
    </xsl:choose>
 
1256
  </xsl:template>
 
1257
 
 
1258
  <xsl:template name="name">
 
1259
    <xsl:param name="partnum"/>
 
1260
    <xsl:choose>
894
1261
      <xsl:when test="ancestor::cref">
895
1262
        <fo:block id="{generate-id(nametext)}">
896
 
          <xsl:value-of select="ret"/><xsl:text> </xsl:text><xsl:value-of select="nametext"/>        
897
 
        </fo:block>   
 
1263
          <xsl:value-of select="ret"/><xsl:text> </xsl:text><xsl:value-of select="nametext"/>
 
1264
        </fo:block>
898
1265
      </xsl:when>
899
1266
      <xsl:otherwise>
900
1267
        <fo:block id="{generate-id(.)}">
901
 
          <xsl:value-of select="."/>                  
902
 
        </fo:block>   
 
1268
          <xsl:value-of select="."/>
 
1269
        </fo:block>
903
1270
      </xsl:otherwise>
904
1271
    </xsl:choose>
905
1272
  </xsl:template>
908
1275
  <!-- Type -->
909
1276
  <xsl:template match="type">
910
1277
    <xsl:param name="partnum"/>
911
 
    
 
1278
 
912
1279
    <fo:block>
913
 
      <xsl:text>Types:</xsl:text>      
 
1280
      <xsl:text>Types:</xsl:text>
914
1281
    </fo:block>
915
1282
 
916
1283
    <fo:list-block xsl:use-attribute-sets="type-listblock">
958
1325
 
959
1326
  <!-- Desc -->
960
1327
  <xsl:template match="desc">
 
1328
    <xsl:param name="partnum"/>
961
1329
 
962
1330
    <xsl:apply-templates>
963
1331
      <xsl:with-param name="partnum" select="$partnum"/>
977
1345
    <xsl:param name="chapnum"/>
978
1346
    <xsl:variable name="tabnum">
979
1347
      <xsl:number level="any" from="chapter" count="table"/>
980
 
    </xsl:variable>   
 
1348
    </xsl:variable>
981
1349
    <fo:table xsl:use-attribute-sets="table">
982
 
    <fo:table-body>      
 
1350
    <fo:table-body>
983
1351
      <xsl:apply-templates select="row">
984
1352
        <xsl:with-param name="chapnum" select="$chapnum"/>
985
1353
        <xsl:with-param name="tabnum" select="$tabnum"/>
1083
1451
  <xsl:template name="calc-arity">
1084
1452
    <xsl:param name="string"/>
1085
1453
    <xsl:param name="no-of-pars"/>
1086
 
   
 
1454
 
1087
1455
    <xsl:variable name="length">
1088
1456
      <xsl:value-of select="string-length($string)"/>
1089
1457
    </xsl:variable>
1092
1460
      <xsl:when test="$length > 0">
1093
1461
        <xsl:call-template name="calc-arity">
1094
1462
          <xsl:with-param name="string" select="substring-after($string, ',')"/>
1095
 
          <xsl:with-param name="no-of-pars" select="$no-of-pars+1"/> 
1096
 
        </xsl:call-template>        
 
1463
          <xsl:with-param name="no-of-pars" select="$no-of-pars+1"/>
 
1464
        </xsl:call-template>
1097
1465
      </xsl:when>
1098
1466
      <xsl:otherwise>
1099
1467
        <xsl:value-of select="$no-of-pars"/>
1103
1471
 
1104
1472
  <xsl:template name="remove-paren">
1105
1473
    <xsl:param name="string"/>
1106
 
   
1107
 
    <xsl:variable name="bstring">
1108
 
      <xsl:value-of select="substring-before($string, '(')"/>
 
1474
 
 
1475
    <xsl:variable name="str1">
 
1476
      <xsl:call-template name="remove-paren-1">
 
1477
        <xsl:with-param name="string" select="$string"/>
 
1478
        <xsl:with-param name="start">(</xsl:with-param>
 
1479
        <xsl:with-param name="end">)</xsl:with-param>
 
1480
      </xsl:call-template>
 
1481
    </xsl:variable>
 
1482
 
 
1483
    <xsl:variable name="str2">
 
1484
      <xsl:call-template name="remove-paren-1">
 
1485
        <xsl:with-param name="string" select="$str1"/>
 
1486
        <xsl:with-param name="start">{</xsl:with-param>
 
1487
        <xsl:with-param name="end">}</xsl:with-param>
 
1488
      </xsl:call-template>
 
1489
    </xsl:variable>
 
1490
 
 
1491
    <xsl:variable name="str3">
 
1492
      <xsl:call-template name="remove-paren-1">
 
1493
        <xsl:with-param name="string" select="$str2"/>
 
1494
        <xsl:with-param name="start">[</xsl:with-param>
 
1495
        <xsl:with-param name="end">]</xsl:with-param>
 
1496
      </xsl:call-template>
 
1497
    </xsl:variable>
 
1498
 
 
1499
    <xsl:value-of select="$str3"/>
 
1500
 
 
1501
  </xsl:template>
 
1502
 
 
1503
 
 
1504
  <xsl:template name="remove-paren-1">
 
1505
    <xsl:param name="string"/>
 
1506
    <xsl:param name="start"/>
 
1507
    <xsl:param name="end"/>
 
1508
 
 
1509
    <xsl:variable name="tmp1">
 
1510
      <xsl:value-of select="substring-before($string, $start)"/>
1109
1511
    </xsl:variable>
1110
1512
 
1111
1513
    <xsl:choose>
1112
 
      <xsl:when test="string-length($bstring) > 0">
1113
 
        <xsl:variable name="astring">
1114
 
          <xsl:value-of select="substring-after($string, ')')"/>
 
1514
      <xsl:when test="string-length($tmp1) > 0 or starts-with($string, $start)">
 
1515
        <xsl:variable name="tmp2">
 
1516
          <xsl:value-of select="substring-after($string, $end)"/>
1115
1517
        </xsl:variable>
1116
1518
        <xsl:variable name="retstring">
1117
1519
          <xsl:call-template name="remove-paren">
1118
 
            <xsl:with-param name="string" select="$astring"/>
1119
 
          </xsl:call-template>        
 
1520
            <xsl:with-param name="string" select="$tmp2"/>
 
1521
          </xsl:call-template>
1120
1522
        </xsl:variable>
1121
 
        <xsl:value-of select="concat($bstring, $retstring)"/>
 
1523
        <xsl:value-of select="concat(concat($tmp1, 'x'), $retstring)"/>
1122
1524
      </xsl:when>
1123
1525
      <xsl:otherwise>
1124
1526
        <xsl:value-of select="$string"/>
1125
1527
      </xsl:otherwise>
1126
1528
    </xsl:choose>
 
1529
 
1127
1530
  </xsl:template>
1128
1531
 
1129
1532
</xsl:stylesheet>