Debian Codegraph @

demo/legacypdf/xslfo/dita2fo-lists.xsl

raw symbols SCIP
1 <?xml version='1.0'?>
2 <!-- This file is part of the DITA Open Toolkit project hosted on
3 Sourceforge.net. See the accompanying license.txt file for
4 applicable licenses.-->
5 <!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
6
7 <!DOCTYPE xsl:transform [
8 <!-- entities for use in the generated output (must produce correctly in FO) -->
9 <!ENTITY rbl "&#160;">
10 <!ENTITY bullet "&#x2022;"><!--check these two for better assignments -->
11 ]>
12
13 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
14 xmlns:fo="http://www.w3.org/1999/XSL/Format"
15 version='1.0'>
16
17
18 <!-- ============ Lists (ul, ol, sl, dl) ============ -->
19 <!-- all dingbat lists start the same way (sl has a null dingbat, in effect) -->
20
21 <xsl:template match="*[contains(@class,' topic/ul ')]|*[contains(@class,' topic/ol ')]|*[contains(@class,' topic/sl ')]">
22 <xsl:variable name="list-type" select="name()" />
23 <xsl:variable name="list-level" select="count(ancestor-or-self::*[name()=$list-type])" />
24 <!--for FOP, delete the provisional attributes below -->
25 <fo:list-block><!-- provisional-distance-between-starts="2pc"
26 provisional-label-separation="2pc"-->
27 <xsl:apply-templates/>
28 </fo:list-block>
29 </xsl:template>
30
31 <xsl:template match="*[contains(@class,' topic/ul ')]/*[contains(@class,' topic/li ')]">
32 <xsl:variable name="list-level"
33 select="count(ancestor-or-self::*[contains(@class,' topic/ul ')] |
34 ancestor-or-self::*[contains(@class,' topic/dl ')] |
35 ancestor-or-self::*[contains(@class,' topic/sl ')] |
36 ancestor-or-self::*[contains(@class,' topic/ol ')] )" />
37 <xsl:variable name="extra-list-indent"><xsl:value-of select="number($list-level)*16"/>pt</xsl:variable>
38 <fo:list-item>
39 <fo:list-item-label end-indent="label-end()" text-align="end">
40 <fo:block>
41 <fo:inline>&#x2022;</fo:inline>
42 </fo:block>
43 </fo:list-item-label>
44 <fo:list-item-body start-indent="body-start()">
45 <!--xsl:attribute name="start-indent"><xsl:value-of select="$basic-start-indent"/> + <xsl:value-of select="$extra-list-indent"/></xsl:attribute-->
46 <fo:block>
47 <xsl:apply-templates />
48 </fo:block>
49 </fo:list-item-body>
50 </fo:list-item>
51 </xsl:template>
52
53
54 <xsl:template match="*[contains(@class,' topic/ol ')]/*[contains(@class,' topic/li ')]">
55 <xsl:variable name="list-level"
56 select="count(ancestor-or-self::*[contains(@class,' topic/ul ')] |
57 ancestor-or-self::*[contains(@class,' topic/dl ')] |
58 ancestor-or-self::*[contains(@class,' topic/sl ')] |
59 ancestor-or-self::*[contains(@class,' topic/ol ')] )" />
60 <xsl:variable name="extra-list-indent"><xsl:value-of select="number($list-level)*16"/>pt</xsl:variable>
61 <fo:list-item>
62 <fo:list-item-label end-indent="label-end()" text-align="end">
63 <fo:block><!-- linefeed-treatment="ignore"-->
64 <xsl:choose>
65 <xsl:when test="($list-level mod 2) = 1">
66 <!-- arabic -->
67 <!--xsl:number format="1." /-->
68 <xsl:value-of select="position()"/>.
69 </xsl:when>
70 <xsl:otherwise>
71 <!-- alphabetic -->
72 <xsl:number format="a." />
73 </xsl:otherwise>
74 </xsl:choose>
75 </fo:block>
76 </fo:list-item-label>
77 <fo:list-item-body start-indent="body-start()">
78 <!--xsl:attribute name="start-indent"><xsl:value-of select="$basic-start-indent"/> + <xsl:value-of select="$extra-list-indent"/></xsl:attribute-->
79 <fo:block>
80 <xsl:apply-templates />
81 </fo:block>
82 </fo:list-item-body>
83 </fo:list-item>
84 </xsl:template>
85
86 <xsl:template match="*[contains(@class,' topic/sl ')]/*[contains(@class,' topic/sli ')]">
87 <xsl:variable name="list-level"
88 select="count(ancestor-or-self::*[contains(@class,' topic/ul ')] |
89 ancestor-or-self::*[contains(@class,' topic/dl ')] |
90 ancestor-or-self::*[contains(@class,' topic/sl ')] |
91 ancestor-or-self::*[contains(@class,' topic/ol ')] )" />
92 <xsl:variable name="extra-list-indent"><xsl:value-of select="number($list-level)*16"/>pt</xsl:variable>
93 <fo:list-item>
94 <fo:list-item-label end-indent="label-end()" text-align="end">
95 <fo:block linefeed-treatment="ignore">
96 <fo:inline><xsl:text> </xsl:text></fo:inline>
97 </fo:block>
98 </fo:list-item-label>
99 <fo:list-item-body start-indent="body-start()">
100 <!--xsl:attribute name="start-indent"><xsl:value-of select="$basic-start-indent"/> + <xsl:value-of select="$extra-list-indent"/></xsl:attribute-->
101 <fo:block>
102 <xsl:apply-templates />
103 </fo:block>
104 </fo:list-item-body>
105 </fo:list-item>
106 </xsl:template>
107
108
109 <xsl:template name="li.name">
110 <xsl:if test="string(@id)"><fo:inline id="{@id}"> </fo:inline></xsl:if>
111 </xsl:template>
112
113 <xsl:template match="*[contains(@class,' topic/itemgroup ')]">
114 <fo:block xsl:use-attribute-sets="p">
115 <!-- setclass -->
116 <xsl:apply-templates select="@compact"/>
117 <!-- set id -->
118 <xsl:apply-templates />
119 </fo:block>
120 </xsl:template>
121
122
123 <!-- ========= definition list group ========== -->
124 <!--
125 wish list:
126 multiple styles (table based, list based with term-based indent, term overlap, etc)
127 -->
128
129 <xsl:template match="*[contains(@class,' topic/dl ')]">
130 <fo:block>
131 <xsl:apply-templates/>
132 </fo:block>
133 </xsl:template>
134
135
136 <xsl:template match="*[contains(@class, ' topic/dlhead ')]">
137 <fo:block font-weight="bold" text-decoration="underline">
138 <xsl:apply-templates />
139 </fo:block>
140 </xsl:template>
141
142
143 <xsl:template match="*[contains(@class,' topic/dthd ')]">
144 <fo:block xsl:use-attribute-sets="dt" font-weight="bold">
145 <!-- setclass -->
146 <!-- set id -->
147 <xsl:call-template name="apply-for-phrases"/>
148 </fo:block>
149 </xsl:template>
150
151
152 <xsl:template match="*[contains(@class,' topic/ddhd ')]">
153 <fo:block xsl:use-attribute-sets="dd" font-weight="bold">
154 <!-- setclass -->
155 <!-- set id -->
156 <xsl:call-template name="apply-for-phrases"/>
157 </fo:block>
158 </xsl:template>
159
160
161 <xsl:template match="*[contains(@class,' topic/dlentry ')]">
162 <fo:block>
163 <xsl:apply-templates/>
164 </fo:block>
165 </xsl:template>
166
167
168
169 <xsl:template match="*[contains(@class,' topic/dt ')]">
170 <fo:block xsl:use-attribute-sets="dt">
171 <!-- setclass -->
172 <!-- set id -->
173 <xsl:choose>
174 <xsl:when test="*"> <!-- tagged content - do not default to bold -->
175 <xsl:apply-templates/>
176 </xsl:when>
177 <xsl:otherwise>
178 <fo:inline font-weight="bold"><xsl:call-template name="apply-for-phrases"/></fo:inline> <!-- text only - bold it -->
179 </xsl:otherwise>
180 </xsl:choose>
181 </fo:block>
182 </xsl:template>
183
184
185 <xsl:template match="*[contains(@class,' topic/dd ')]">
186 <xsl:variable name="list-level"
187 select="count(ancestor-or-self::*[contains(@class,' topic/ul ')] |
188 ancestor-or-self::*[contains(@class,' topic/dl ')] |
189 ancestor-or-self::*[contains(@class,' topic/sl ')] |
190 ancestor-or-self::*[contains(@class,' topic/ol ')] )" />
191 <xsl:variable name="extra-list-indent"><xsl:value-of select="number($list-level)*16"/>pt</xsl:variable>
192 <fo:block>
193 <xsl:attribute name="start-indent"><xsl:value-of select="$basic-start-indent"/> + <xsl:value-of select="$extra-list-indent"/></xsl:attribute>
194 <!--
195 start-indent="{$basic-start-indent} + {
196 count(ancestor-or-self::*[contains(@class,' topic/ul ')]) +
197 count(ancestor-or-self::*[contains(@class,' topic/ol ')]) +
198 count(ancestor-or-self::*[contains(@class,' topic/dl ')])}em"
199 -->
200 <!-- setclass -->
201 <!-- set id -->
202 <xsl:apply-templates />
203 </fo:block>
204 </xsl:template>
205
206 <!-- case of dl within a table cell -->
207 <xsl:template match="*[contains(@class,' topic/entry ')]//*[contains(@class,' topic/dd ')]">
208 <fo:block xsl:use-attribute-sets="dd.cell">
209 <!-- setclass -->
210 <!-- set id -->
211 <xsl:apply-templates />
212 </fo:block>
213 </xsl:template>
214
215 <!-- case of dl within a simpletable cell -->
216 <xsl:template match="*[contains(@class,' topic/stentry ')]//*[contains(@class,' topic/dd ')]" priority="2">
217 <fo:block xsl:use-attribute-sets="dd.cell">
218 <!-- setclass -->
219 <!-- set id -->
220 <xsl:apply-templates />
221 </fo:block>
222 </xsl:template>
223
224 <!-- =================== end of element rules ====================== -->
225
226
227 </xsl:stylesheet>