root/trunk/xml/lgtpdf.xsl

Revision 4662, 15.1 KB (checked in by pmoura, 6 days ago)

Updated copyright notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet
3    version="1.0"
4    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5    xmlns:fo="http://www.w3.org/1999/XSL/Format">
6
7
8<!--
9================================================================
10Logtalk - Open source object-oriented logic programming language
11Release 2.35.0
12
13Copyright (c) 1998-2009 Paulo Moura.        All Rights Reserved.
14Logtalk is free software.  You can redistribute it and/or modify
15it under the terms of the "Artistic License 2.0" as published by
16The Perl Foundation. Consult the "LICENSE.txt" file for details.
17================================================================
18-->
19
20
21<xsl:output
22    method="xml"
23    indent="yes"
24    encoding="utf-8"/>
25
26
27<xsl:param name="format"/>
28
29<xsl:variable name="height">
30    <xsl:choose>
31        <xsl:when test="$format='a4'">297mm</xsl:when>
32        <xsl:when test="$format='us'">11.0in</xsl:when>
33        <xsl:otherwise>297mm</xsl:otherwise>
34    </xsl:choose>
35</xsl:variable>
36
37<xsl:variable name="width">
38    <xsl:choose>
39        <xsl:when test="$format='a4'">210mm</xsl:when>
40        <xsl:when test="$format='us'">8.5in</xsl:when>
41        <xsl:otherwise>210mm</xsl:otherwise>
42    </xsl:choose>
43</xsl:variable>
44
45
46<xsl:template match ="/">
47
48    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
49
50        <fo:layout-master-set>
51            <fo:simple-page-master
52                    master-name="simple"
53                    page-height="{$height}" 
54                    page-width="{$width}"
55                    margin-top="15mm" 
56                    margin-bottom="15mm" 
57                    margin-left="25mm" 
58                    margin-right="25mm">
59                <fo:region-body margin-top="15mm" margin-bottom="15mm"/>
60                <fo:region-before extent="15mm"/>
61                <fo:region-after extent="15mm"/>
62            </fo:simple-page-master>
63        </fo:layout-master-set>
64
65        <fo:page-sequence master-reference="simple">
66       
67            <fo:static-content flow-name="xsl-region-before">
68                <fo:block>
69                    <fo:leader leader-pattern="rule" leader-length.optimum="100%"/>
70                </fo:block>
71                <fo:block
72                        text-align="end" 
73                        font-size="9pt" 
74                        font-family="sans-serif"
75                        font-weight="bold">
76                    <xsl:value-of select="logtalk/entity/type"/>: <xsl:value-of select="logtalk/entity/name"/>
77                </fo:block>
78            </fo:static-content> 
79
80            <fo:static-content flow-name="xsl-region-after">
81                <fo:block>
82                    <fo:leader leader-pattern="rule" leader-length.optimum="100%"/>
83                </fo:block>
84                <fo:block
85                        text-align="end" 
86                        font-size="9pt" 
87                        font-family="sans-serif"
88                        font-weight="bold">
89                    <fo:page-number/> of <fo:page-number-citation ref-id="end"/>
90                </fo:block>
91            </fo:static-content> 
92   
93            <fo:flow flow-name="xsl-region-body">
94                <fo:block
95                        font-size="18pt" 
96                        font-family="sans-serif" 
97                        font-weight="bold"
98                        space-after="8pt">
99                    <xsl:value-of select="logtalk/entity/name"/>
100                </fo:block>
101                <xsl:apply-templates select="logtalk/entity"/>
102                <xsl:apply-templates select="logtalk/relations"/>
103                <xsl:apply-templates select="logtalk/predicates"/>
104                <xsl:apply-templates select="logtalk/remarks"/>
105                <fo:block id="end"/>
106            </fo:flow>
107
108        </fo:page-sequence>
109
110    </fo:root>
111
112</xsl:template>
113
114
115<xsl:template match="logtalk/entity">
116
117    <xsl:if test="comment">
118        <fo:block
119                margin-left="10mm"
120                font-size="10pt"
121                font-family="serif" 
122                font-style="italic">
123            <xsl:value-of select="comment"/>
124        </fo:block>
125    </xsl:if>
126
127    <xsl:if test="parameters">
128        <fo:block
129                font-size="9pt"
130                font-family="monospace"
131                margin-left="10mm"
132                space-before="4pt">
133        </fo:block>
134        <xsl:for-each select="parameters/parameter">
135            <fo:block
136                    font-size="9pt"
137                    font-family="monospace"
138                    margin-left="10mm">
139                <xsl:value-of select="name"/> - <xsl:value-of select="description"/>
140            </fo:block>
141        </xsl:for-each>
142    </xsl:if>
143
144    <xsl:if test="author">
145        <fo:block
146                font-size="10pt"
147                font-family="serif" 
148                keep-with-next="always"
149                space-before="8pt">
150            author:
151        </fo:block>
152        <fo:block
153                font-size="9pt"
154                font-family="monospace"
155                margin-left="10mm">
156            <xsl:value-of select="author"/>
157        </fo:block>
158    </xsl:if>
159
160    <xsl:if test="version">
161        <fo:block
162                font-size="10pt"
163                font-family="serif" 
164                keep-with-next="always">
165            version:
166        </fo:block>
167        <fo:block
168                font-size="9pt"
169                font-family="monospace"
170                margin-left="10mm">
171            <xsl:value-of select="version"/>
172        </fo:block>
173    </xsl:if>
174
175    <xsl:if test="date">
176        <fo:block
177                font-size="10pt"
178                font-family="serif" 
179                keep-with-next="always">
180            date:
181        </fo:block>
182        <fo:block
183                font-size="9pt"
184                font-family="monospace"
185                margin-left="10mm">
186            <xsl:value-of select="date"/>
187        </fo:block>
188    </xsl:if>
189
190    <xsl:if test="copyright">
191        <fo:block
192                font-size="10pt"
193                font-family="serif" 
194                keep-with-next="always">
195            copyright:
196        </fo:block>
197        <fo:block
198                font-size="9pt"
199                font-family="monospace"
200                margin-left="10mm">
201            <xsl:value-of select="copyright"/>
202        </fo:block>
203    </xsl:if>
204
205    <xsl:if test="license">
206        <fo:block
207                font-size="10pt"
208                font-family="serif" 
209                keep-with-next="always">
210            license:
211        </fo:block>
212        <fo:block
213                font-size="9pt"
214                font-family="monospace"
215                margin-left="10mm">
216            <xsl:value-of select="license"/>
217        </fo:block>
218    </xsl:if>
219
220    <fo:block
221            font-size="10pt"
222            font-family="serif"
223            space-before="8pt"
224            keep-with-next="always">
225        compilation:
226    </fo:block>
227    <fo:block
228            font-size="9pt"
229            font-family="monospace"
230            margin-left="10mm" 
231            space-after="4pt">
232        <xsl:value-of select="compilation"/>
233    </fo:block>
234
235    <xsl:if test="info">
236        <xsl:for-each select="info">
237            <fo:block
238                    font-size="10pt"
239                    font-family="serif" 
240                    keep-with-next="always">
241                <xsl:value-of select="key"/>:
242            </fo:block>
243            <fo:block
244                    font-size="9pt"
245                    font-family="monospace"
246                    margin-left="10mm">
247                <xsl:value-of select="value"/>
248            </fo:block>
249        </xsl:for-each>
250    </xsl:if>
251
252</xsl:template>
253
254
255<xsl:template match="logtalk/relations">
256    <fo:block
257            font-size="10pt"
258            font-family="serif"
259            space-before="4pt">
260    </fo:block>
261    <xsl:choose>
262        <xsl:when test="*">
263            <xsl:if test="implements">
264                <fo:block
265                        font-size="10pt"
266                        font-family="serif" 
267                        keep-with-next="always">
268                    implements:
269                </fo:block>
270                <xsl:apply-templates select="implements"/>
271            </xsl:if>
272            <xsl:if test="imports">
273                <fo:block
274                        font-size="10pt"
275                        font-family="serif" 
276                        keep-with-next="always">
277                    imports:
278                </fo:block>
279                <xsl:apply-templates select="imports"/>
280            </xsl:if>
281            <xsl:if test="extends">
282                <fo:block
283                        font-size="10pt"
284                        font-family="serif" 
285                        keep-with-next="always">
286                    extends:
287                </fo:block>
288                <xsl:apply-templates select="extends"/>
289            </xsl:if>
290            <xsl:if test="instantiates">
291                <fo:block
292                        font-size="10pt"
293                        font-family="serif" 
294                        keep-with-next="always">
295                    instantiates:
296                </fo:block>
297                <xsl:apply-templates select="instantiates"/>
298            </xsl:if>
299            <xsl:if test="specializes">
300                <fo:block
301                        font-size="10pt"
302                        font-family="serif" 
303                        keep-with-next="always">
304                    specializes:
305                </fo:block>
306                <xsl:apply-templates select="specializes"/>
307            </xsl:if>
308            <xsl:if test="uses">
309                <fo:block
310                        font-size="10pt"
311                        font-family="serif" 
312                        keep-with-next="always">
313                    uses:
314                </fo:block>
315                <xsl:apply-templates select="uses"/>
316            </xsl:if>
317            <xsl:if test="calls">
318                <fo:block
319                        font-size="10pt"
320                        font-family="serif" 
321                        keep-with-next="always">
322                    calls:
323                </fo:block>
324                <xsl:apply-templates select="calls"/>
325            </xsl:if>
326        </xsl:when>
327        <xsl:otherwise> 
328            <fo:block
329                    font-size="10pt" 
330                    font-family="serif" 
331                    font-style="italic"
332                    space-before="4pt">
333                (no dependencies on other files)
334            </fo:block>
335        </xsl:otherwise>
336    </xsl:choose>
337</xsl:template>
338
339
340<xsl:template match="logtalk/relations/uses">
341    <fo:block
342            font-size="9pt"
343            font-family="monospace"
344            margin-left="10mm">
345        <xsl:value-of select="name"/>
346    </fo:block>
347</xsl:template>
348
349
350<xsl:template match="logtalk/relations/calls">
351    <fo:block
352            font-size="9pt"
353            font-family="monospace"
354            margin-left="10mm">
355        <xsl:value-of select="name"/>
356    </fo:block>
357</xsl:template>
358
359
360<xsl:template match="logtalk/relations/*">
361    <fo:block
362            font-size="9pt"
363            font-family="monospace"
364            margin-left="10mm">
365        <xsl:value-of select="scope"/><xsl:text> </xsl:text><xsl:value-of select="name"/>
366    </fo:block>
367</xsl:template>
368
369
370<xsl:template match="logtalk/predicates">
371
372    <fo:block
373            font-size="14pt" 
374            font-family="sans-serif" 
375            font-weight="bold" 
376            keep-with-next="always"
377            space-before="18pt">
378        Public interface
379    </fo:block>
380    <xsl:choose>
381        <xsl:when test="public/predicate">
382            <xsl:apply-templates select="public/predicate"/>
383        </xsl:when>
384        <xsl:when test="/logtalk/relations/*">     
385            <fo:block
386                    font-size="10pt" 
387                    font-family="serif" 
388                    font-style="italic"
389                    space-before="10pt">
390                (see related entities)
391            </fo:block>
392        </xsl:when>
393        <xsl:otherwise>
394            <fo:block
395                    font-size="10pt" 
396                    font-family="serif" 
397                    font-style="italic"
398                    space-before="10pt">
399                (none)
400            </fo:block>
401        </xsl:otherwise>
402    </xsl:choose>
403
404    <fo:block
405            font-size="14pt" 
406            font-family="sans-serif" 
407            font-weight="bold" 
408            keep-with-next="always"
409            space-before="18pt">
410        Protected interface
411    </fo:block>
412    <xsl:choose>
413        <xsl:when test="protected/predicate">
414            <xsl:apply-templates select="protected/predicate"/>
415        </xsl:when>
416        <xsl:when test="/logtalk/relations/*">     
417            <fo:block
418                    font-size="10pt" 
419                    font-family="serif" 
420                    font-style="italic"
421                    space-before="10pt">
422                (see related entities)
423            </fo:block>
424        </xsl:when>
425        <xsl:otherwise>
426            <fo:block
427                    font-size="10pt" 
428                    font-family="serif" 
429                    font-style="italic"
430                    space-before="10pt">
431                (none)
432            </fo:block>
433        </xsl:otherwise>
434    </xsl:choose>
435
436    <fo:block
437            font-size="14pt" 
438            font-family="sans-serif" 
439            font-weight="bold" 
440            keep-with-next="always"
441            space-before="18pt">
442        Private predicates
443    </fo:block>
444    <xsl:choose>
445        <xsl:when test="private/predicate">
446            <xsl:apply-templates select="private/predicate"/>
447        </xsl:when>
448        <xsl:when test="/logtalk/relations/*">     
449            <fo:block
450                    font-size="10pt" 
451                    font-family="serif" 
452                    font-style="italic"
453                    space-before="10pt">
454                (see related entities)
455            </fo:block>
456        </xsl:when>
457        <xsl:otherwise>
458            <fo:block
459                    font-size="10pt" 
460                    font-family="serif" 
461                    font-style="italic"
462                    space-before="10pt">
463                (none)
464            </fo:block>
465        </xsl:otherwise>
466    </xsl:choose>
467
468</xsl:template>
469
470
471<xsl:template match="*/predicate">
472
473    <fo:block
474            font-size="12pt" 
475            font-family="sans-serif" 
476            font-weight="bold" 
477            keep-with-next="always"
478            space-before="10pt">
479        <xsl:value-of select="name"/>
480    </fo:block>
481
482    <xsl:if test="comment">
483        <fo:block
484                margin-left="10mm"
485                font-size="10pt" 
486                font-family="serif" 
487                font-style="italic"
488                space-before="4pt" 
489                space-after="8pt">
490            <xsl:value-of select="comment"/>
491        </fo:block>
492    </xsl:if>
493
494    <fo:block
495            font-size="10pt"
496            font-family="serif"
497            keep-with-next="always">
498        compilation:
499    </fo:block>
500    <fo:block
501            font-size="9pt"
502            font-family="monospace"
503            margin-left="10mm">
504        <xsl:value-of select="compilation"/>
505    </fo:block>
506
507    <xsl:if test="template">
508        <fo:block
509                font-size="10pt"
510                font-family="serif" 
511                keep-with-next="always"
512                space-before="4pt">
513            template:
514        </fo:block>
515        <fo:block
516                font-size="9pt"
517                font-family="monospace"
518                margin-left="10mm">
519            <xsl:value-of select="template"/>
520        </fo:block>
521    </xsl:if>
522
523    <xsl:if test="arguments">
524        <fo:block
525                font-size="9pt"
526                font-family="monospace"
527                margin-left="10mm"
528                space-before="4pt">
529        </fo:block>
530        <xsl:for-each select="arguments/argument">
531            <fo:block
532                    margin-left="10mm">
533                <fo:inline font-size="9pt" font-family="monospace"><xsl:value-of select="name"/></fo:inline>
534                <fo:inline font-size="10pt" font-family="serif" font-style="italic"> - <xsl:value-of select="description"/></fo:inline>
535            </fo:block>
536        </xsl:for-each>
537    </xsl:if>
538
539    <xsl:if test="meta">
540        <fo:block
541                font-size="10pt"
542                font-family="serif" 
543                keep-with-next="always"
544                space-before="4pt">
545            meta-predicate template:
546        </fo:block>
547        <fo:block
548                font-size="9pt"
549                font-family="monospace"
550                margin-left="10mm">
551            <xsl:value-of select="meta"/>
552        </fo:block>
553    </xsl:if>
554
555    <xsl:if test="mode">
556        <fo:block
557                font-size="10pt"
558                font-family="serif" 
559                keep-with-next="always"
560                space-before="4pt">
561            mode - number of solutions:
562        </fo:block>
563        <xsl:for-each select="mode">
564            <fo:block
565                    font-size="9pt"
566                    font-family="monospace"
567                    margin-left="10mm">
568                <xsl:value-of select="template"/> - <xsl:value-of select="solutions"/>
569            </fo:block>
570        </xsl:for-each>
571    </xsl:if>
572
573    <xsl:if test="exceptions">
574        <fo:block
575                font-size="10pt"
576                font-family="serif" 
577                keep-with-next="always"
578                space-before="4pt">
579            exceptions:
580        </fo:block>
581        <xsl:for-each select="exceptions/exception">
582            <fo:block
583                    font-size="10pt"
584                    font-family="serif" 
585                    keep-with-next="always"
586                    margin-left="10mm">
587                <xsl:value-of select="condition" />:
588            </fo:block>
589            <fo:block
590                    font-size="9pt"
591                    font-family="monospace"
592                    margin-left="20mm">
593                <xsl:value-of select="term" />
594            </fo:block>
595        </xsl:for-each>
596    </xsl:if>
597
598    <xsl:if test="examples">
599        <fo:block
600                font-size="10pt"
601                font-family="serif" 
602                keep-with-next="always"
603                space-before="4pt">
604            examples:
605        </fo:block>
606        <xsl:for-each select="examples/example">
607            <fo:block
608                    font-size="10pt"
609                    font-family="serif"
610                    font-style="italic"
611                    keep-with-next="always"
612                    margin-left="10mm">
613                <xsl:value-of select="description" />
614            </fo:block>
615            <fo:block
616                    font-size="9pt"
617                    font-family="monospace"
618                    margin-left="20mm">
619                <xsl:value-of select="call" />
620            </fo:block>
621            <fo:block
622                    font-size="9pt"
623                    font-family="monospace"
624                    margin-left="20mm" 
625                    space-after="4pt">
626                <xsl:value-of select="bindings" />
627            </fo:block>
628        </xsl:for-each>
629    </xsl:if>
630
631    <xsl:if test="info">
632        <xsl:for-each select="info">
633            <fo:block
634                    font-size="10pt"
635                    font-family="serif" 
636                    keep-with-next="always"
637                    space-before="4pt">
638                    <xsl:value-of select="key"/>:
639                </fo:block>
640            <fo:block
641                    font-size="9pt"
642                    font-family="monospace"
643                    margin-left="10mm">
644                <xsl:value-of select="value"/>
645            </fo:block>
646        </xsl:for-each>
647    </xsl:if>
648
649</xsl:template>
650
651
652<xsl:template match="logtalk/remarks">
653
654    <fo:block
655            font-size="14pt" 
656            font-family="sans-serif" 
657            font-weight="bold" 
658            keep-with-next="always"
659            space-before="18pt">
660        Remarks
661    </fo:block>
662    <xsl:choose>
663        <xsl:when test="*">
664            <xsl:for-each select="remark">
665                <fo:block
666                        font-size="10pt"
667                        font-family="serif"
668                        font-style="italic"
669                        keep-with-next="always"
670                        space-before="10pt">
671                    <xsl:value-of select="topic" />
672                </fo:block>
673                <fo:block
674                        font-size="10pt"
675                        font-family="serif"
676                        margin-left="10mm">
677                    <xsl:value-of select="text" />
678                </fo:block>
679            </xsl:for-each>
680        </xsl:when>
681        <xsl:otherwise> 
682            <fo:block
683                    font-size="10pt" 
684                    font-family="serif" 
685                    font-style="italic"
686                    space-before="10pt">
687                (none)
688            </fo:block>
689        </xsl:otherwise>
690    </xsl:choose>
691
692</xsl:template>
693
694
695</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.