Whamcloud - gitweb
LUDOC-11 misc: remove some 'l23' conditions add 'l2C'
[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 = 'l23'">Introduced in Lustre 2.3</xsl:when>
150                         <xsl:when test="@condition = 'l24'">Introduced in Lustre 2.4</xsl:when>
151                         <xsl:when test="@condition = 'l25'">Introduced in Lustre 2.5</xsl:when>
152                         <xsl:when test="@condition = 'l26'">Introduced in Lustre 2.6</xsl:when>
153                         <xsl:when test="@condition = 'l27'">Introduced in Lustre 2.7</xsl:when>
154                         <xsl:when test="@condition = 'l28'">Introduced in Lustre 2.8</xsl:when>
155                         <xsl:when test="@condition = 'l29'">Introduced in Lustre 2.9</xsl:when>
156                         <xsl:when test="@condition = 'l2A'">Introduced in Lustre 2.10</xsl:when>
157                         <xsl:when test="@condition = 'l2B'">Introduced in Lustre 2.11</xsl:when>
158                         <xsl:when test="@condition = 'l2C'">Introduced in Lustre 2.11</xsl:when>
159                         <xsl:otherwise>Documentation Error: unrecognised condition attribute</xsl:otherwise>
160                 </xsl:choose>
161         </xsl:variable>
162     <xsl:choose>
163         <xsl:when test="name(..) = 'part'">
164                 <xsl:call-template name='mychapter'>
165                 <xsl:with-param name='version' select="$versionstr"/>
166                 <xsl:with-param name='chunkid' select="$id"/>
167             </xsl:call-template>
168                 </xsl:when>
169                 <xsl:otherwise>
170             <xsl:call-template name='textdecoration_1'>
171                 <xsl:with-param name='version' select="$versionstr"/>
172                                 <xsl:with-param name='content' select="$content"/>
173                 <xsl:with-param name='chunkid' select="$id"/>
174             </xsl:call-template>
175                 </xsl:otherwise>
176     </xsl:choose>
177 </xsl:template>
178
179 <!-- toc.line template: This template over loads the behavior of creating the table of contents. It
180                 adds in a small entry to identify lustre version specific features.
181                 for more information, see this page:
182                 http://xml.web.cern.ch/XML/www.sagehill.net/xml/docbookxsl/PrintCustomEx.html#PrintTocEntries -->
183 <xsl:template name="toc.line">
184         <xsl:variable name="id">
185                 <xsl:call-template name="object.id"/>
186         </xsl:variable>
187         <xsl:variable name="lustrecond">
188                 <xsl:choose>
189                         <xsl:when test="@condition='l23'">L 2.3</xsl:when>
190                         <xsl:when test="@condition='l24'">L 2.4</xsl:when>
191                         <xsl:when test="@condition='l25'">L 2.5</xsl:when>
192                         <xsl:when test="@condition='l26'">L 2.6</xsl:when>
193                         <xsl:when test="@condition='l27'">L 2.7</xsl:when>
194                         <xsl:when test="@condition='l28'">L 2.8</xsl:when>
195                         <xsl:when test="@condition='l29'">L 2.9</xsl:when>
196                         <xsl:when test="@condition='l2A'">L 2.10</xsl:when>
197                         <xsl:when test="@condition='l2B'">L 2.11</xsl:when>
198                         <xsl:when test="@condition='l2C'">L 2.11</xsl:when>
199                         <xsl:otherwise></xsl:otherwise>
200                 </xsl:choose>
201         </xsl:variable>
202
203         <xsl:variable name="label">
204                 <xsl:apply-templates select="." mode="label.markup"/>
205         </xsl:variable>
206         <fo:block text-align-last="justify"
207                         end-indent="{$toc.indent.width}pt"
208                         last-line-end-indent="-{$toc.indent.width}pt">
209                 <fo:inline keep-with-next.within-line="always">
210                         <xsl:choose>
211                                 <xsl:when test="local-name(.) = 'chapter'">
212                                         <xsl:attribute name="font-weight">bold</xsl:attribute>
213                                 </xsl:when>
214                         </xsl:choose>
215                         <fo:basic-link internal-destination="{$id}">
216                                 <xsl:if test="$label != ''">
217                                         <xsl:copy-of select="$label"/>
218                                         <xsl:value-of select="$autotoc.label.separator"/>
219                                 </xsl:if>
220                                 <xsl:apply-templates select="." mode="title.markup"/>
221                         </fo:basic-link>
222                 </fo:inline>
223                 <fo:inline keep-together.within-line="always">
224                         <xsl:text> </xsl:text>
225                         <fo:leader leader-pattern="dots"
226                                         leader-pattern-width="3pt"
227                                         leader-alignment="reference-area"
228                                         keep-with-next.within-line="always"/>
229                         <xsl:text>  </xsl:text>
230                         <xsl:value-of select='$lustrecond'/>
231                         <xsl:text>  </xsl:text>
232                         <fo:basic-link internal-destination="{$id}">
233                                 <fo:page-number-citation ref-id="{$id}"/>
234                         </fo:basic-link>
235                 </fo:inline>
236         </fo:block>
237 </xsl:template>
238
239 </xsl:stylesheet>