Whamcloud - gitweb
LUDOC-11 misc: remove pre-2.5 conditional text
[doc/manual.git] / style / customstyle_fo.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3         xmlns:fo="http://www.w3.org/1999/XSL/Format"
4         xmlns:d="http://docbook.org/ns/docbook"
5         exclude-result-prefixes="d"
6         version="1.0" >
7 <!-- xsl:import takes place at compile time. For this reason, I sed in the correct
8      primary xsl pdf, and then run xsltproc -->
9 <xsl:import href="PRIMARYXSL"/>
10 <xsl:output method='xml'/>
11
12 <xsl:param name="fop1.extensions" select="1"></xsl:param>
13 <xsl:param name="chapter.autolabel" select="1"></xsl:param>
14 <xsl:param name="section.autolabel" select="1"></xsl:param>
15 <xsl:param name="appendix.autolabel" select="1"></xsl:param>
16 <xsl:param name="autotoc.label.in.hyperlink" select="1"></xsl:param>
17 <xsl:param name="section.label.includes.component.label" select="1"></xsl:param>
18
19 <!-- TODO: ideally generalize customstyle_common.xsl suffeciently
20      so that is can be included in this file. Currently, this file
21          duplicates customerstyle_common.xsl with some minor differences. -->
22
23 <!-- textdecoration_1: a template to highlight regions of text.-->
24 <xsl:template name='textdecoration_1'>
25         <xsl:param name='version'/>
26         <xsl:param name='content'/>
27         <xsl:param name='id'/>
28         <fo:block id="{id}">
29         <fo:block-container
30                 padding='5pt'
31                 border-color='gray'
32                 border-style='solid'
33                 border-width='1pt'>
34                 <fo:block-container float='left' text-indent='3px' start-indent='-20px'>
35                         <fo:block background-color="gray">
36                                 <xsl:value-of select='$version'/>
37                         </fo:block>
38                 </fo:block-container>
39                 <fo:block text-indent='0px' start-indent='0px'>
40                         <xsl:copy-of select="$content"/>
41                 </fo:block>
42                 </fo:block-container>
43         </fo:block>
44 </xsl:template>
45
46 <!-- mychapter definition This has been copied from xsl-ns-stylesheets/fo/component.xsl 
47         and modified to provide highlight regions of text for an entire chapter. 
48         This is consistent with the high-lighting provided by textdecoration_1 !-->
49 <xsl:template name="mychapter">
50         <xsl:param name='version'/>
51         <xsl:param name='chunkid'/>
52   <xsl:variable name="id">
53     <xsl:call-template name="object.id"/>
54   </xsl:variable>
55
56   <xsl:variable name="master-reference">
57     <xsl:call-template name="select.pagemaster"/>
58   </xsl:variable>
59
60   <fo:page-sequence hyphenate="{$hyphenate}"
61                     master-reference="{$master-reference}">
62     <xsl:attribute name="language">
63       <xsl:call-template name="l10n.language"/>
64     </xsl:attribute>
65     <xsl:attribute name="format">
66       <xsl:call-template name="page.number.format">
67         <xsl:with-param name="master-reference" select="$master-reference"/>
68       </xsl:call-template>
69     </xsl:attribute>
70     <xsl:attribute name="initial-page-number">
71       <xsl:call-template name="initial.page.number">
72         <xsl:with-param name="master-reference" select="$master-reference"/>
73       </xsl:call-template>
74     </xsl:attribute>
75
76     <xsl:attribute name="force-page-count">
77       <xsl:call-template name="force.page.count">
78         <xsl:with-param name="master-reference" select="$master-reference"/>
79       </xsl:call-template>
80     </xsl:attribute>
81
82     <xsl:attribute name="hyphenation-character">
83       <xsl:call-template name="gentext">
84         <xsl:with-param name="key" select="'hyphenation-character'"/>
85       </xsl:call-template>
86     </xsl:attribute>
87     <xsl:attribute name="hyphenation-push-character-count">
88       <xsl:call-template name="gentext">
89         <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
90       </xsl:call-template>
91     </xsl:attribute>
92     <xsl:attribute name="hyphenation-remain-character-count">
93       <xsl:call-template name="gentext">
94         <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
95       </xsl:call-template>
96     </xsl:attribute>
97
98     <xsl:apply-templates select="." mode="running.head.mode">
99       <xsl:with-param name="master-reference" select="$master-reference"/>
100     </xsl:apply-templates>
101
102     <xsl:apply-templates select="." mode="running.foot.mode">
103       <xsl:with-param name="master-reference" select="$master-reference"/>
104     </xsl:apply-templates>
105
106     <fo:flow flow-name="xsl-region-body">
107       <xsl:call-template name="set.flow.properties">
108         <xsl:with-param name="element" select="local-name(.)"/>
109         <xsl:with-param name="master-reference" select="$master-reference"/>
110       </xsl:call-template>
111
112         <fo:block-container id='chapterdecoration-{$chunkid}'
113                         padding='5pt'
114                         border-color='gray'
115                         border-style='solid'
116                         border-width='1pt'>
117                         <fo:block-container float='left' text-indent='3px' start-indent='-20px'>
118                                 <fo:block background-color="gray">
119                                         <xsl:value-of select='$version'/>
120                                 </fo:block>
121                         </fo:block-container>
122                   <fo:block id="{$id}"
123                                         xsl:use-attribute-sets="component.titlepage.properties">
124                         <xsl:call-template name="chapter.titlepage"/>
125                   </fo:block>
126
127                   <!-- RHEL and SLES versions have an older docbook xsl install
128                        that fails on this call: 
129                            xsl:call-template name="make.component.tocs"/-->
130
131                   <xsl:apply-templates/>
132       </fo:block-container>
133     </fo:flow>
134   </fo:page-sequence>
135 </xsl:template>
136
137
138 <!-- conditional matching template: this calls text decoration
139           template with the correct variables. -->
140 <xsl:template match="*[@condition]">
141         <xsl:param name="content">
142                 <xsl:apply-imports/>
143         </xsl:param>
144     <xsl:variable name="id">
145         <xsl:call-template name="object.id"/>
146     </xsl:variable>
147         <xsl:variable name="versionstr">
148                 <xsl:choose>
149                         <xsl:when test="@condition = 'l25'">Introduced in Lustre 2.5</xsl:when>
150                         <xsl:when test="@condition = 'l26'">Introduced in Lustre 2.6</xsl:when>
151                         <xsl:when test="@condition = 'l27'">Introduced in Lustre 2.7</xsl:when>
152                         <xsl:when test="@condition = 'l28'">Introduced in Lustre 2.8</xsl:when>
153                         <xsl:when test="@condition = 'l29'">Introduced in Lustre 2.9</xsl:when>
154                         <xsl:when test="@condition = 'l2A'">Introduced in Lustre 2.10</xsl:when>
155                         <xsl:when test="@condition = 'l2B'">Introduced in Lustre 2.11</xsl:when>
156                         <xsl:when test="@condition = 'l2C'">Introduced in Lustre 2.12</xsl:when>
157                         <xsl:when test="@condition = 'l2D'">Introduced in Lustre 2.13</xsl:when>
158                         <xsl:when test="@condition = 'l2E'">Introduced in Lustre 2.14</xsl:when>
159                         <xsl:when test="@condition = 'l2F'">Introduced in Lustre 2.15</xsl:when>
160                         <xsl:when test="@condition = 'l2G'">Introduced in Lustre 2.16</xsl:when>
161                         <xsl:otherwise>Documentation Error: unrecognised condition attribute</xsl:otherwise>
162                 </xsl:choose>
163         </xsl:variable>
164     <xsl:choose>
165         <xsl:when test="name(..) = 'part'">
166                 <xsl:call-template name='mychapter'>
167                 <xsl:with-param name='version' select="$versionstr"/>
168                 <xsl:with-param name='chunkid' select="$id"/>
169             </xsl:call-template>
170                 </xsl:when>
171                 <xsl:otherwise>
172             <xsl:call-template name='textdecoration_1'>
173                 <xsl:with-param name='version' select="$versionstr"/>
174                                 <xsl:with-param name='content' select="$content"/>
175                 <xsl:with-param name='chunkid' select="$id"/>
176             </xsl:call-template>
177                 </xsl:otherwise>
178     </xsl:choose>
179 </xsl:template>
180
181 <!-- toc.line template: This template over loads the behavior of creating the table of contents. It
182                 adds in a small entry to identify lustre version specific features.
183                 for more information, see this page:
184                 http://xml.web.cern.ch/XML/www.sagehill.net/xml/docbookxsl/PrintCustomEx.html#PrintTocEntries -->
185 <xsl:template name="toc.line">
186         <xsl:variable name="id">
187                 <xsl:call-template name="object.id"/>
188         </xsl:variable>
189         <xsl:variable name="lustrecond">
190                 <xsl:choose>
191                         <xsl:when test="@condition='l23'">L 2.3</xsl:when>
192                         <xsl:when test="@condition='l24'">L 2.4</xsl:when>
193                         <xsl:when test="@condition='l25'">L 2.5</xsl:when>
194                         <xsl:when test="@condition='l26'">L 2.6</xsl:when>
195                         <xsl:when test="@condition='l27'">L 2.7</xsl:when>
196                         <xsl:when test="@condition='l28'">L 2.8</xsl:when>
197                         <xsl:when test="@condition='l29'">L 2.9</xsl:when>
198                         <xsl:when test="@condition='l2A'">L 2.10</xsl:when>
199                         <xsl:when test="@condition='l2B'">L 2.11</xsl:when>
200                         <xsl:when test="@condition='l2C'">L 2.12</xsl:when>
201                         <xsl:when test="@condition='l2D'">L 2.13</xsl:when>
202                         <xsl:otherwise></xsl:otherwise>
203                 </xsl:choose>
204         </xsl:variable>
205
206         <xsl:variable name="label">
207                 <xsl:apply-templates select="." mode="label.markup"/>
208         </xsl:variable>
209         <fo:block text-align-last="justify"
210                         end-indent="{$toc.indent.width}pt"
211                         last-line-end-indent="-{$toc.indent.width}pt">
212                 <fo:inline keep-with-next.within-line="always">
213                         <xsl:choose>
214                                 <xsl:when test="local-name(.) = 'chapter'">
215                                         <xsl:attribute name="font-weight">bold</xsl:attribute>
216                                 </xsl:when>
217                         </xsl:choose>
218                         <fo:basic-link internal-destination="{$id}">
219                                 <xsl:if test="$label != ''">
220                                         <xsl:copy-of select="$label"/>
221                                         <xsl:value-of select="$autotoc.label.separator"/>
222                                 </xsl:if>
223                                 <xsl:apply-templates select="." mode="title.markup"/>
224                         </fo:basic-link>
225                 </fo:inline>
226                 <fo:inline keep-together.within-line="always">
227                         <xsl:text> </xsl:text>
228                         <fo:leader leader-pattern="dots"
229                                         leader-pattern-width="3pt"
230                                         leader-alignment="reference-area"
231                                         keep-with-next.within-line="always"/>
232                         <xsl:text>  </xsl:text>
233                         <xsl:value-of select='$lustrecond'/>
234                         <xsl:text>  </xsl:text>
235                         <fo:basic-link internal-destination="{$id}">
236                                 <fo:page-number-citation ref-id="{$id}"/>
237                         </fo:basic-link>
238                 </fo:inline>
239         </fo:block>
240 </xsl:template>
241
242 </xsl:stylesheet>