Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/boostbook/xsl/caramel/concept2docbook.xsl @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 28.7 KB
Line 
1<?xml version="1.0" ?>
2
3<!--
4Copyright (c) 2002-2003 The Trustees of Indiana University.
5                        All rights reserved.
6Copyright (c) 2000-2001 University of Notre Dame. All rights reserved.
7
8   Distributed under the Boost Software License, Version 1.0.
9   (See accompanying file LICENSE_1_0.txt or copy at
10   http://www.boost.org/LICENSE_1_0.txt)
11-->
12
13<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
14  <xsl:strip-space elements="* xsl:*"/>
15
16  <xsl:include href="unparser.xsl"/>
17
18  <xsl:key name="concepts" match="concept" use="@name"/>
19
20  <!-- The layout type to use for concept descriptions. Can be one of:
21       sgi: simulate the SGI STL documentation
22       austern: simulate the documentation in Generic Programming and the STL,
23         by Matthew H. Austern
24       caramel: simulate the formatting from Caramel
25       -->
26  <xsl:param name="boost.concept.layout" select="'austern'"/>
27
28  <xsl:template match="concept">
29    <refentry>
30      <xsl:attribute name="id">
31        <xsl:call-template name="generate.id"/>
32      </xsl:attribute>
33
34      <refmeta>
35        <refentrytitle>Concept <xsl:value-of select="@name"/></refentrytitle>
36        <manvolnum>7</manvolnum>
37      </refmeta>
38
39      <refnamediv>
40        <refname><xsl:value-of select="@name"/></refname>
41        <xsl:if test="purpose">
42          <refpurpose>
43            <xsl:apply-templates select="purpose/*|purpose/text()"/>
44          </refpurpose>
45        </xsl:if>
46      </refnamediv>
47
48      <!--
49      <refentryinfo>
50        <xsl:for-each select="copyright | copyright-include | legalnotice">
51          <xsl:choose>
52            <xsl:when test="name(.)='copyright'">
53              <copyright><xsl:copy-of select="./node()"/></copyright>
54            </xsl:when>
55            <xsl:when test="name(.)='legalnotice'">
56              <legalnotice><xsl:copy-of select="./node()"/></legalnotice>
57            </xsl:when>
58            <xsl:when test="name(.)='copyright-include'">
59              <copyright><xsl:copy-of select="document(concat('../concepts/', @file))/copyright/node()"/></copyright>
60            </xsl:when>
61          </xsl:choose>
62        </xsl:for-each>
63      </refentryinfo>
64-->
65
66    <xsl:if test="description">
67      <xsl:if test="description">
68        <refsect1>
69          <title>Description</title>
70          <xsl:for-each select="description">
71            <xsl:apply-templates/>
72          </xsl:for-each>
73        </refsect1>
74      </xsl:if>
75    </xsl:if>
76
77    <xsl:if test="refines | refines-when-mutable">
78      <refsect1>
79        <title>Refinement of</title>
80        <itemizedlist>
81          <xsl:if test="refines">
82            <xsl:for-each select="refines">
83              <listitem>
84                <para>
85                  <xsl:call-template name="concept.link">
86                    <xsl:with-param name="name" select="@concept"/>
87                  </xsl:call-template>
88                </para>
89              </listitem>
90            </xsl:for-each>
91          </xsl:if>
92          <xsl:if test="refines-when-mutable">
93            <xsl:for-each select="refines-when-mutable">
94              <listitem>
95                <para>
96                  <xsl:text>When mutable: </xsl:text>
97                  <xsl:call-template name="concept.link">
98                    <xsl:with-param name="name" select="@concept"/>
99                  </xsl:call-template>
100                </para>
101              </listitem>
102            </xsl:for-each>
103          </xsl:if>
104        </itemizedlist>
105      </refsect1>
106    </xsl:if>
107
108    <!-- This part must be run even if there are no associated types to print out, so the hidden type definitions can be found -->
109    <xsl:variable name="definition_list">
110      <xsl:call-template name="make-definition-list">
111        <xsl:with-param name="typedefs" select="define-type | associated-type"/>
112        <xsl:with-param name="definition_list">
113          <xsl:for-each select="param/@name">
114            @(@<xsl:value-of select="."/>=<xsl:value-of select="."/>@)@
115          </xsl:for-each>
116        </xsl:with-param>
117      </xsl:call-template>
118    </xsl:variable>
119
120    <!-- <xsl:message>Definition list: <xsl:value-of select="$definition_list"/></xsl:message> -->
121
122    <xsl:call-template name="print-associated-types">
123      <xsl:with-param name="typedefs" select="associated-type"/>
124      <xsl:with-param name="definition_list" select="$definition_list"/>
125    </xsl:call-template>
126
127    <xsl:call-template name="concept.notation">
128      <xsl:with-param name="definition_list" select="$definition_list"/>
129    </xsl:call-template>
130
131    <xsl:variable name="notations">
132      <xsl:for-each select="notation">
133        @@(@@<xsl:call-template name="unparse-cpp">
134          <xsl:with-param name="typeref" select="*[1]"/>
135          <xsl:with-param name="definition_list" select="$definition_list"/>
136          <xsl:with-param name="ignore-cv" select="true()"/>
137          <xsl:with-param name="ignore-references" select="true()"/>
138        </xsl:call-template>@@=@@<xsl:value-of select="normalize-space(@variables)"/>@@)@@
139      </xsl:for-each>
140    </xsl:variable>
141
142    <!-- <xsl:message>Notations: <xsl:value-of select="normalize-space($notations)"/> End notations</xsl:message> -->
143
144    <xsl:if test="definition">
145      <refsect1>
146      <title>Definitions</title>
147        <xsl:for-each select="definition">
148          <p><xsl:apply-templates/></p>
149        </xsl:for-each>
150      </refsect1>
151    </xsl:if>
152
153    <xsl:if test="valid-type-expression | models | models-when-mutable">
154      <refsect1>
155        <title>Type expressions</title>
156        <variablelist>
157          <xsl:for-each select="models">
158            <varlistentry>
159              <term/>
160              <listitem>
161                <para>
162                  <xsl:call-template name="unparse-operator-definition">
163                    <xsl:with-param name="typeref" select="."/>
164                    <xsl:with-param name="operator_nodeset" select="key('concepts', @concept)/models-sentence/node()"/>
165                    <xsl:with-param name="definition_list" select="$definition_list"/>
166                    <xsl:with-param name="notations" select="$notations"/>
167                    <xsl:with-param name="ignore-cv" select="false()"/>
168                    <xsl:with-param name="self" select="@concept"/>
169                    <xsl:with-param name="use-code-block" select="true()"/>
170                  </xsl:call-template>
171                </para>
172              </listitem>
173            </varlistentry>
174          </xsl:for-each>
175          <xsl:for-each select="models-when-mutable">
176            <varlistentry>
177              <term>Only when mutable</term>
178              <listitem>
179                <para>
180                  <xsl:call-template name="unparse-operator-definition">
181                    <xsl:with-param name="typeref" select="."/>
182                    <xsl:with-param name="operator_nodeset" select="key('concepts', @concept)/models-sentence/node()"/>
183                    <xsl:with-param name="definition_list" select="$definition_list"/>
184                    <xsl:with-param name="notations" select="$notations"/>
185                    <xsl:with-param name="ignore-cv" select="false()"/>
186                    <xsl:with-param name="self" select="@concept"/>
187                    <xsl:with-param name="use-code-block" select="true()"/>
188                  </xsl:call-template>
189                </para>
190              </listitem>
191            </varlistentry>
192          </xsl:for-each>
193          <xsl:for-each select="valid-type-expression">
194            <varlistentry>
195              <term><xsl:value-of select="@name"/></term>
196              <listitem>
197                <para>
198                  <type>
199                    <xsl:call-template name="unparse-cpp">
200                      <xsl:with-param name="typeref" select="*[2]"/>
201                      <xsl:with-param name="definition_list" select="$definition_list"/>
202                      <xsl:with-param name="notations" select="normalize-space($notations)"/>
203                    </xsl:call-template>
204                  </type>
205                 
206                  <xsl:comment/> must be
207                  <xsl:for-each select="return-type/*">
208                    <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
209                    <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
210                    <xsl:call-template name="unparse-constraint">
211                      <xsl:with-param name="constraint" select="."/>
212                      <xsl:with-param name="definition_list" select="$definition_list"/>
213                      <xsl:with-param name="type-expr-mode" select="true()"/>
214                    </xsl:call-template>
215                  </xsl:for-each><xsl:comment/>.
216                </para>
217               
218                <xsl:if test="description">
219                  <xsl:for-each select="description">
220                    <xsl:apply-templates/>
221                  </xsl:for-each>
222                </xsl:if>
223              </listitem>
224            </varlistentry>
225          </xsl:for-each>
226        </variablelist>
227      </refsect1>
228    </xsl:if>
229
230    <xsl:if test="valid-expression">
231      <refsect1>
232      <title>Valid expressions</title>
233
234      <xsl:variable name="columns">
235        <xsl:if test="valid-expression/return-type">
236          <xsl:text>T</xsl:text>
237        </xsl:if>
238        <xsl:if test="valid-expression/precondition">
239          <xsl:text>P</xsl:text>
240        </xsl:if>
241        <xsl:if test="valid-expression/semantics">
242          <xsl:text>S</xsl:text>
243        </xsl:if>
244        <xsl:if test="valid-expression/postcondition">
245          <xsl:text>O</xsl:text>
246        </xsl:if>
247      </xsl:variable>
248
249      <informaltable>
250        <tgroup>
251          <xsl:attribute name="cols">
252            <xsl:value-of select="string-length($columns) + 2"/>
253          </xsl:attribute>
254          <thead>
255            <row>
256              <entry>Name</entry>
257              <entry>Expression</entry>
258              <xsl:if test="contains($columns, 'T')">
259                <entry>Type</entry>
260              </xsl:if>
261              <xsl:if test="contains($columns, 'P')">
262                <entry>Precondition</entry>
263              </xsl:if>
264              <xsl:if test="contains($columns, 'S')">
265                <entry>Semantics</entry>
266              </xsl:if>
267              <xsl:if test="contains($columns, 'O')">
268                <entry>Postcondition</entry>
269              </xsl:if>
270            </row>
271          </thead>
272          <tbody>
273            <xsl:apply-templates select="valid-expression">
274              <xsl:with-param name="definition_list" 
275                select="$definition_list"/>
276              <xsl:with-param name="notations" 
277                select="normalize-space($notations)"/>
278              <xsl:with-param name="columns" select="$columns"/>
279            </xsl:apply-templates>
280          </tbody>
281        </tgroup>
282      </informaltable>
283      <!-- Doug prefers the table
284      <variablelist>
285        <xsl:for-each select="valid-expression">
286          <xsl:variable name="as-cxx-value">
287            <xsl:call-template name="unparse-cpp">
288              <xsl:with-param name="typeref" select="*[1]"/>
289              <xsl:with-param name="definition_list" select="$definition_list"/>
290              <xsl:with-param name="notations" select="normalize-space($notations)"/>
291            </xsl:call-template>
292          </xsl:variable>
293          <varlistentry>
294            <term><xsl:value-of select="@name"/>: <literal><xsl:value-of select="$as-cxx-value"/></literal></term>
295            <listitem><variablelist>
296              <xsl:if test="return-type/*">
297                <varlistentry><term>Return value</term><listitem><para>
298                  <xsl:for-each select="return-type/*">
299                    <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
300                    <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
301                    <xsl:call-template name="unparse-constraint">
302                      <xsl:with-param name="constraint" select="."/>
303                      <xsl:with-param name="definition_list" select="$definition_list"/>
304                      <xsl:with-param name="capitalize" select="position()=1"/>
305                    </xsl:call-template>
306                  </xsl:for-each>
307                </para></listitem></varlistentry>
308              </xsl:if>
309
310              <xsl:for-each select="precondition">
311                <varlistentry><term>Precondition</term><listitem><para>
312                  <xsl:apply-templates/>
313                </para></listitem></varlistentry>
314              </xsl:for-each>
315
316              <xsl:for-each select="semantics">
317                <varlistentry><term>Semantics</term><listitem><para>
318                  <xsl:apply-templates/>
319                </para></listitem></varlistentry>
320              </xsl:for-each>
321
322              <xsl:for-each select="postcondition">
323                <varlistentry><term>Postcondition</term><listitem><para>
324                  <xsl:apply-templates/>
325                </para></listitem></varlistentry>
326              </xsl:for-each>
327
328            </variablelist></listitem>
329          </varlistentry>
330
331        </xsl:for-each>
332      </variablelist>
333-->
334      </refsect1>
335    </xsl:if>
336
337    <xsl:if test="complexity">
338      <refsect1>
339      <title>Complexity</title>
340        <xsl:for-each select="complexity">
341          <para><xsl:apply-templates/></para>
342        </xsl:for-each>
343      </refsect1>
344    </xsl:if>
345
346    <xsl:if test="invariant">
347      <refsect1>
348      <title>Invariants</title>
349      <variablelist>
350        <xsl:for-each select="invariant">
351          <varlistentry>
352            <term><xsl:value-of select="@name"/></term>
353            <listitem>
354              <para><xsl:apply-templates/></para>
355            </listitem>
356          </varlistentry>
357        </xsl:for-each>
358      </variablelist>
359      </refsect1>
360    </xsl:if>
361
362    <xsl:if test="example-model">
363      <refsect1>
364      <title>Models</title>
365        <itemizedlist>
366        <xsl:for-each select="example-model">
367          <listitem>
368            <simplelist type="inline">
369            <xsl:for-each select="*">
370              <xsl:variable name="example-value">
371                <xsl:call-template name="unparse-cpp">
372                  <xsl:with-param name="typeref" select="."/>
373                  <xsl:with-param name="definition_list" select="$definition_list"/>
374                </xsl:call-template>
375              </xsl:variable>
376              <member><type><xsl:value-of select="$example-value"/></type></member>
377            </xsl:for-each>
378            </simplelist>
379          </listitem>
380        </xsl:for-each>
381        </itemizedlist>
382      </refsect1>
383    </xsl:if>
384
385    <xsl:variable name="see-also-list" select="concept-ref | see-also | refines | refines-when-mutable | models-as-first-arg | models | models-when-mutable"/>
386    <xsl:if test="$see-also-list">
387      <refsect1>
388      <title>See also</title>
389      <itemizedlist>
390        <xsl:for-each select="$see-also-list">
391          <xsl:sort select="string(@name|@concept)" data-type="text"/>
392          <xsl:if test="string(@name|@concept) != string(../@name)">
393            <xsl:if test="not(string(@name|@concept) = (preceding::*/@name | preceding::*/@concept | ancestor::*/@name | ancestor::*/@concept))">
394              <listitem>
395                <para>
396                  <xsl:call-template name="concept.link">
397                    <xsl:with-param name="name" select="@name|@concept"/>
398                  </xsl:call-template>
399                </para>
400              </listitem>
401            </xsl:if>
402          </xsl:if>
403        </xsl:for-each>
404      </itemizedlist>
405      </refsect1>
406    </xsl:if>
407
408  </refentry>
409  </xsl:template>
410
411  <xsl:template name="unparse-constraint">
412    <xsl:param name="constraint"/>
413    <xsl:param name="definition_list"/>
414    <xsl:param name="type-expr-mode" select="false()"/>
415    <xsl:param name="capitalize" select="true()"/>
416
417    <xsl:choose>
418
419      <xsl:when test="name($constraint)='require-same-type'">
420        <xsl:if test="$type-expr-mode">identical to </xsl:if>
421        <type>
422          <xsl:call-template name="unparse-cpp">
423            <xsl:with-param name="typeref" select="$constraint/*[1]"/>
424            <xsl:with-param name="definition_list" select="definition_list"/>
425          </xsl:call-template>
426        </type>
427      </xsl:when>
428
429      <xsl:when test="name($constraint)='convertible-to'">
430        <xsl:choose>
431          <xsl:when test="$type-expr-mode">convertible to </xsl:when>
432          <xsl:when test="not($type-expr-mode) and $capitalize">Convertible to </xsl:when>
433          <xsl:when test="not($type-expr-mode) and not($capitalize)">convertible to </xsl:when>
434        </xsl:choose>
435        <type>
436          <xsl:call-template name="unparse-cpp">
437            <xsl:with-param name="typeref" select="$constraint/*[1]"/>
438            <xsl:with-param name="definition_list" select="definition_list"/>
439          </xsl:call-template>
440        </type>
441      </xsl:when>
442
443      <xsl:when test="name($constraint)='derived-from'">
444        <xsl:choose>
445          <xsl:when test="$type-expr-mode">derived from </xsl:when>
446          <xsl:when test="not($type-expr-mode) and $capitalize">Derived from </xsl:when>
447          <xsl:when test="not($type-expr-mode) and not($capitalize)">derived from </xsl:when>
448        </xsl:choose>
449        <type>
450          <xsl:call-template name="unparse-cpp">
451            <xsl:with-param name="typeref" select="$constraint/*[1]"/>
452            <xsl:with-param name="definition_list" select="definition_list"/>
453          </xsl:call-template>
454        </type>
455      </xsl:when>
456
457      <xsl:when test="name($constraint)='assignable-to'">
458        <xsl:choose>
459          <xsl:when test="$type-expr-mode">assignable to </xsl:when>
460          <xsl:when test="not($type-expr-mode) and $capitalize">Assignable to </xsl:when>
461          <xsl:when test="not($type-expr-mode) and not($capitalize)">assignable to </xsl:when>
462        </xsl:choose>
463        <type>
464          <xsl:call-template name="unparse-cpp">
465            <xsl:with-param name="typeref" select="$constraint/*[1]"/>
466            <xsl:with-param name="definition_list" select="definition_list"/>
467          </xsl:call-template>
468        </type>
469      </xsl:when>
470
471      <xsl:when test="name($constraint)='models-as-first-arg'">
472        <xsl:choose>
473          <xsl:when test="$type-expr-mode"> a model </xsl:when>
474          <xsl:when test="not($type-expr-mode) and $capitalize"> Models </xsl:when>
475          <xsl:when test="not($type-expr-mode) and not($capitalize)"> models </xsl:when>
476        </xsl:choose>
477        <xsl:if test="$constraint/*"><xsl:comment/>
478          (along with <xsl:for-each select="$constraint/*"><type>
479              <xsl:call-template name="unparse-cpp">
480                <xsl:with-param name="typeref" select="."/>
481                <xsl:with-param name="definition_list" select="definition_list"/>
482              </xsl:call-template>
483            </type>
484            <xsl:choose>
485              <xsl:when test="position()=last()"/>
486              <xsl:when test="position()=last()-1 and last()=2"> and </xsl:when>
487              <xsl:when test="position()=last()-1 and last()!=2">, and </xsl:when>
488              <xsl:otherwise>, </xsl:otherwise>
489            </xsl:choose><xsl:comment/>
490          </xsl:for-each><xsl:comment/>) <xsl:comment/>
491        </xsl:if><xsl:comment/>
492        <xsl:if test="$type-expr-mode"> of </xsl:if>
493        <xsl:call-template name="concept.link">
494          <xsl:with-param name="name" select="$constraint/@concept"/>
495        </xsl:call-template>
496      </xsl:when>
497
498    </xsl:choose>
499  </xsl:template>
500
501  <xsl:template name="make-definition-list">
502    <xsl:param name="typedefs"/>
503    <xsl:param name="definition_list"/>
504
505    <xsl:choose>
506      <xsl:when test="$typedefs">
507        <xsl:variable name="type_definition">
508          <xsl:if test="name($typedefs[1]/*[1])!='description'">
509            <xsl:call-template name="unparse-cpp">
510              <xsl:with-param name="typeref" select="$typedefs[1]/*[1]"/>
511              <xsl:with-param name="definition_list" select="$definition_list"/>
512            </xsl:call-template>
513          </xsl:if>
514        </xsl:variable>
515
516        <xsl:variable name="new_type_definition">
517          <xsl:choose>
518            <xsl:when test="name($typedefs[1])='associated-type'">
519              <xsl:value-of select="$typedefs[1]/@name"/>
520            </xsl:when>
521            <xsl:otherwise>
522              <xsl:value-of select="$type_definition"/>
523            </xsl:otherwise>
524          </xsl:choose>
525        </xsl:variable>
526
527        <xsl:call-template name="make-definition-list">
528          <xsl:with-param name="typedefs" select="$typedefs[position()!=1]"/>
529          <xsl:with-param name="definition_list" select="concat($definition_list, ' @(@', $typedefs[1]/@name, '=', $new_type_definition, '@)@')"/>
530        </xsl:call-template>
531
532      </xsl:when>
533
534      <xsl:otherwise> <!-- End of expression list, emit the results that have accumulated -->
535        <xsl:value-of select="$definition_list"/>
536      </xsl:otherwise>
537    </xsl:choose>
538  </xsl:template>
539
540  <xsl:template name="print-associated-types">
541    <xsl:param name="typedefs"/>
542    <xsl:param name="definition_list"/>
543
544    <xsl:if test="$typedefs">
545      <refsect1>
546        <title>Associated types</title>
547
548        <xsl:choose>
549          <xsl:when test="$boost.concept.layout='sgi'">
550            <informaltable>
551              <tgroup cols="2">
552                <tbody>
553                  <xsl:apply-templates select="associated-type" mode="sgi">
554                    <xsl:with-param name="definition_list" 
555                      select="$definition_list"/>
556                  </xsl:apply-templates>
557                </tbody>
558              </tgroup>
559            </informaltable>
560          </xsl:when>
561          <xsl:when test="$boost.concept.layout='austern'">
562            <itemizedlist>
563              <xsl:apply-templates select="associated-type" mode="austern">
564                <xsl:with-param name="definition_list" 
565                  select="$definition_list"/>
566              </xsl:apply-templates>
567            </itemizedlist>
568          </xsl:when>
569          <xsl:when test="$boost.concept.layout='caramel'">
570            <segmentedlist>
571              <segtitle>Name</segtitle>
572              <segtitle>Code</segtitle>
573              <segtitle>Description</segtitle>
574              <xsl:for-each select="$typedefs">
575                <xsl:variable name="type_definition">
576                  <xsl:call-template name="unparse-cpp">
577                    <xsl:with-param name="typeref" select="*[1]"/>
578                    <xsl:with-param name="definition_list" select="$definition_list"/>
579                  </xsl:call-template>
580                </xsl:variable>
581                <seglistitem>
582                  <seg><xsl:value-of select="@name"/></seg>
583                  <seg><xsl:value-of select="$type_definition"/></seg>
584                  <seg>
585                    <xsl:for-each select="description">
586                      <xsl:call-template name="description"/>
587                    </xsl:for-each>
588                  </seg>
589                </seglistitem>
590              </xsl:for-each>
591            </segmentedlist>           
592          </xsl:when>
593        </xsl:choose>
594      </refsect1>
595    </xsl:if>
596  </xsl:template>
597
598  <xsl:template name="comma-list">
599    <xsl:param name="list"/>
600
601    <xsl:if test="$list!=''">
602      <term><varname>
603        <xsl:if test="substring-before($list,' ')=''"><xsl:value-of select="$list"/></xsl:if>
604        <xsl:value-of select="substring-before($list,' ')"/>
605      </varname></term>
606      <xsl:call-template name="comma-list">
607        <xsl:with-param name="list" select="substring-after($list,' ')"/>
608      </xsl:call-template>
609    </xsl:if>
610  </xsl:template>
611
612  <xsl:template match="associated-type" mode="sgi">
613    <row>
614      <entry><simpara><xsl:value-of select="@name"/></simpara></entry>
615
616      <entry>
617        <para>
618          <xsl:for-each select="description">
619            <xsl:apply-templates/>
620          </xsl:for-each>
621        </para>
622      </entry>
623    </row>
624  </xsl:template>
625
626  <xsl:template match="associated-type" mode="austern">
627    <xsl:param name="definition_list" select="''"/>
628
629    <listitem>
630      <para>
631        <emphasis role="bold"><xsl:value-of select="@name"/></emphasis>
632     
633        <xsl:call-template name="preformatted">
634          <xsl:with-param name="text">
635            <xsl:call-template name="unparse-cpp">
636              <xsl:with-param name="typeref" select="*[1]"/>
637              <xsl:with-param name="definition_list" select="$definition_list"/>
638            </xsl:call-template>
639          </xsl:with-param>
640        </xsl:call-template>
641       
642        <xsl:for-each select="description">
643          <xsl:apply-templates/>
644        </xsl:for-each>
645      </para>
646    </listitem>
647  </xsl:template>
648
649  <xsl:template match="valid-expression">
650    <xsl:param name="definition_list"/>
651    <xsl:param name="notations"/>
652    <xsl:param name="columns"/>
653
654    <row>
655      <entry><simpara><xsl:value-of select="@name"/></simpara></entry>
656
657      <entry>
658        <simpara>
659          <xsl:call-template name="unparse-cpp">
660            <xsl:with-param name="typeref" select="*[1]"/>
661            <xsl:with-param name="definition_list" select="$definition_list"/>
662            <xsl:with-param name="notations" select="$notations"/>
663          </xsl:call-template>
664        </simpara>
665      </entry>
666
667      <xsl:if test="contains($columns, 'T')">
668        <entry>
669          <simpara>
670            <xsl:for-each select="return-type/*">
671              <xsl:if test="position()!=1 and last()!=2">, </xsl:if>
672              <xsl:if test="position()=last() and last()!=1"> and </xsl:if>
673              <xsl:call-template name="unparse-constraint">
674                <xsl:with-param name="constraint" select="."/>
675                <xsl:with-param name="definition_list" 
676                  select="$definition_list"/>
677                <xsl:with-param name="capitalize" select="position()=1"/>
678              </xsl:call-template>
679            </xsl:for-each>         
680          </simpara>
681        </entry>
682      </xsl:if>
683
684      <xsl:if test="contains($columns, 'P')">
685        <entry>
686          <xsl:for-each select="precondition">
687            <simpara><xsl:apply-templates/></simpara>
688          </xsl:for-each>
689        </entry>
690      </xsl:if>
691
692      <xsl:if test="contains($columns, 'S')">
693        <entry>
694          <xsl:for-each select="semantics">
695            <simpara><xsl:apply-templates/></simpara>
696          </xsl:for-each>
697        </entry>
698      </xsl:if>
699
700      <xsl:if test="contains($columns, 'O')">
701        <entry>
702          <xsl:for-each select="postcondition">
703            <simpara><xsl:apply-templates/></simpara>
704          </xsl:for-each>
705        </entry>
706      </xsl:if>
707    </row>
708  </xsl:template>
709
710  <xsl:template name="concept.notation">
711    <xsl:param name="definition_list"/>
712
713    <refsect1>
714      <title>Notation</title>
715      <variablelist>
716        <xsl:for-each select="param">
717          <varlistentry>
718            <term><xsl:value-of select="@name"/></term>
719            <listitem>
720              <simpara>
721                <xsl:text>A type playing the role of </xsl:text>
722                <xsl:value-of select="@role"/>
723                <xsl:text> in the </xsl:text>
724                <xsl:call-template name="concept.link">
725                  <xsl:with-param name="name" select="../@name"/>
726                </xsl:call-template>
727                <xsl:text> concept.</xsl:text>
728              </simpara>
729            </listitem>
730          </varlistentry>
731        </xsl:for-each>
732        <xsl:for-each select="notation">
733          <xsl:variable name="notation_name">
734            <xsl:call-template name="comma-list">
735              <xsl:with-param name="list" 
736                select="normalize-space(@variables)"/>
737            </xsl:call-template>
738          </xsl:variable>
739
740          <varlistentry>
741            <xsl:copy-of select="$notation_name"/>
742            <listitem>
743              <simpara>
744                <xsl:variable name="output-plural" select="substring-before(normalize-space(@variables),' ')!=''"/>
745                <xsl:if test="name(*[1])='sample-value'">Object<xsl:if test="$output-plural">s</xsl:if> of type </xsl:if>
746                <xsl:variable name="typeref-to-print" select="*[name()!='sample-value'] | sample-value/*[name()!='sample-value']"/>
747                <xsl:call-template name="unparse-cpp">
748                  <xsl:with-param name="typeref" select="$typeref-to-print"/>
749                  <xsl:with-param name="definition_list" select="$definition_list"/>
750                  <xsl:with-param name="ignore-cv" select="true()"/>
751                  <xsl:with-param name="ignore-references" select="true()"/>
752                </xsl:call-template>
753              </simpara>
754            </listitem>
755          </varlistentry>
756        </xsl:for-each>
757      </variablelist>
758    </refsect1>   
759  </xsl:template>
760
761  <xsl:template name="concept.link">
762    <xsl:param name="name" select="text()"/>
763    <xsl:param name="warn" select="true()"/>
764    <xsl:param name="text" select="$name"/>
765    <xsl:variable name="node" select="key('concepts', $name)"/>
766   
767    <xsl:choose>
768      <xsl:when test="count($node)=0">
769        <xsl:if test="$warn">
770          <xsl:message>
771            <xsl:text>warning: cannot find concept '</xsl:text>
772            <xsl:value-of select="$name"/>
773            <xsl:text>'</xsl:text>
774          </xsl:message>
775        </xsl:if>
776        <xsl:value-of select="$text"/>
777      </xsl:when>
778      <xsl:otherwise>
779        <xsl:call-template name="internal-link">
780          <xsl:with-param name="to">
781            <xsl:call-template name="generate.id">
782              <xsl:with-param name="node" select="$node"/>
783            </xsl:call-template>
784          </xsl:with-param>
785          <xsl:with-param name="text" select="$text"/>
786        </xsl:call-template>
787      </xsl:otherwise>
788    </xsl:choose>   
789  </xsl:template>
790
791  <xsl:template name="remove-whitespace">
792    <xsl:param name="text" select="text()"/>
793
794    <xsl:variable name="normalized" select="normalize-space($text)"/>
795    <xsl:choose>
796      <xsl:when test="contains($normalized, ' ')">
797        <xsl:value-of select="substring-before($normalized, ' ')"/>
798        <xsl:call-template name="remove-whitespace">
799          <xsl:with-param name="text" 
800            select="substring-after($normalized, ' ')"/>
801        </xsl:call-template>
802      </xsl:when>
803      <xsl:otherwise>
804        <xsl:value-of select="$normalized"/>
805      </xsl:otherwise>
806    </xsl:choose>
807  </xsl:template>
808
809  <xsl:template match="concept" mode="generate.id">
810    <xsl:call-template name="remove-whitespace">
811      <xsl:with-param name="text" select="@name"/>
812    </xsl:call-template>
813  </xsl:template>
814</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.