VirtualBox

source: vbox/trunk/src/libs/dita-ot-1.8.5/plugins/legacypdf/xslfo/dita2fo-titles.xsl@ 99507

最後變更 在這個檔案從99507是 98584,由 vboxsync 提交於 2 年 前

Docs: bugref:10302. Setting svn properties of DITA-OT library.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 9.8 KB
 
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<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:fo="http://www.w3.org/1999/XSL/Format"
9 version='1.0'>
10
11
12
13<!-- =================== start of element rules ====================== -->
14
15<!-- NESTED TOPIC TITLES (sensitive to nesting depth, but are still processed for contained markup) -->
16
17<!-- h1 -->
18<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]" priority="2">
19 <fo:block xsl:use-attribute-sets="topictitle1" padding-top="1.4pc">
20 <fo:block border-top-color="black" border-top-width="3pt" line-height="100%"
21 border-left-width="0pt" border-right-width="0pt">
22 <xsl:call-template name="get-title"/>
23 </fo:block>
24 </fo:block>
25</xsl:template>
26
27<!-- h2 -->
28<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]" priority="3">
29 <fo:block xsl:use-attribute-sets="topictitle2" padding-top="1pc">
30 <fo:block border-top-color="black" border-top-width="1pt"
31 border-left-width="0pt" border-right-width="0pt">
32 <xsl:call-template name="get-title"/>
33 </fo:block>
34 </fo:block>
35</xsl:template>
36
37<!-- h3 -->
38<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]" priority="4">
39 <fo:block xsl:use-attribute-sets="topictitle3">
40 <xsl:call-template name="get-title"/>
41 </fo:block>
42</xsl:template>
43
44<!-- h4 -->
45<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]" priority="5">
46 <fo:block xsl:use-attribute-sets="topictitle4">
47 <xsl:if test="$trace='yes'"><fo:inline color="purple"></fo:inline></xsl:if>
48 <xsl:call-template name="get-title"/>
49 </fo:block>
50</xsl:template>
51
52<!-- h5 -->
53<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]" priority="6">
54 <fo:block xsl:use-attribute-sets="topictitle5">
55 <xsl:call-template name="get-title"/><xsl:text>: </xsl:text>
56 </fo:block>
57</xsl:template>
58
59<!-- h6 -->
60<xsl:template match="*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/topic ')]/*[contains(@class,' topic/title ')]" priority="7">
61 <fo:block xsl:use-attribute-sets="topictitle6">
62 <xsl:call-template name="get-title"/><xsl:text>: </xsl:text>
63 </fo:block>
64</xsl:template>
65
66
67<!-- section/title handling -->
68
69<xsl:template match="*[contains(@class,' topic/section ')]/*[contains(@class,' topic/title ')]">
70 <fo:block font-weight="bold">
71 <xsl:apply-templates/>
72 </fo:block>
73</xsl:template>
74
75
76<!-- example/title handing -->
77
78<xsl:template match="*[contains(@class,' topic/example ')]/*[contains(@class,' topic/title ')]">
79 <fo:block font-weight="bold">
80 <xsl:apply-templates/>
81 </fo:block>
82</xsl:template>
83
84
85<!-- table/title handling -->
86
87<xsl:template match="*[contains(@class,' topic/table ')]/*[contains(@class,' topic/title ')]">
88 <xsl:variable name="tbl-pfx-txt">
89 <xsl:call-template name="getString">
90 <xsl:with-param name="stringName" select="'Table'"/>
91 </xsl:call-template>
92 <xsl:value-of select="count(preceding::*[contains(@class,' topic/table ')]/*[contains(@class,' topic/title ')])+1"/>
93 </xsl:variable>
94 <fo:block font-weight="bold">
95 <fo:inline color="red"><xsl:value-of select="$tbl-pfx-txt"/>. </fo:inline>
96 <xsl:apply-templates/>
97 </fo:block>
98</xsl:template>
99
100
101<!-- fig/title handling -->
102
103<xsl:template match="*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')]">
104 <xsl:variable name="fig-pfx-txt">
105 <xsl:call-template name="getString">
106 <xsl:with-param name="stringName" select="'Figure'"/>
107 </xsl:call-template>
108 <xsl:value-of select="count(preceding::*[contains(@class,' topic/fig ')]/*[contains(@class,' topic/title ')])+1"/>
109 </xsl:variable>
110 <fo:block font-weight="bold">
111 <fo:inline color="red"><xsl:value-of select="$fig-pfx-txt"/>. </fo:inline>
112 <xsl:apply-templates/>
113 </fo:block>
114</xsl:template>
115
116
117
118
119<xsl:template name="place-tbl-lbl">
120<xsl:variable name="tbl-count"> <!-- Number of table/title's before this one -->
121 <xsl:number count="*/table/title" level="multiple"/> <!-- was ANY-->
122</xsl:variable>
123<xsl:variable name="tbl-count-actual"> <!-- Number of table/title's including this one -->
124 <xsl:choose>
125 <xsl:when test="not($tbl-count&gt;0) and not($tbl-count=0) and not($tbl-count&lt;0)">1</xsl:when>
126 <xsl:otherwise><xsl:value-of select="$tbl-count+1"/></xsl:otherwise>
127 </xsl:choose>
128</xsl:variable>
129 <xsl:choose>
130 <xsl:when test="*[contains(@class,' topic/title ')]">
131 <fo:block><fo:inline font-weight="bold">
132 <xsl:call-template name="getString">
133 <xsl:with-param name="stringName" select="'Table'"/>
134 </xsl:call-template><xsl:text> </xsl:text><xsl:value-of select="$tbl-count-actual"/>.<xsl:text> </xsl:text>
135 <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="exhibittitle"/>
136 </fo:inline>
137 <xsl:if test="*[contains(@class,' topic/desc ')]">
138 <xsl:text>. </xsl:text><xsl:apply-templates select="*[contains(@class,' topic/desc ')]" mode="exhibitdesc"/>
139 </xsl:if>
140 </fo:block>
141 </xsl:when>
142 <xsl:when test="*[contains(@class,' topic/desc ')]">
143 <fo:block>****<xsl:value-of select="*[contains(@class,' topic/desc ')]"/></fo:block>
144 </xsl:when>
145 </xsl:choose>
146</xsl:template>
147
148
149<xsl:template name="place-fig-lbl">
150<xsl:variable name="fig-count"> <!-- Number of fig/title's before this one -->
151 <xsl:number count="*/fig/title" level="multiple"/>
152</xsl:variable>
153<xsl:variable name="fig-count-actual"> <!-- Number of fig/title's including this one -->
154 <xsl:choose>
155 <xsl:when test="not($fig-count&gt;0) and not($fig-count=0) and not($fig-count&lt;0)">1</xsl:when>
156 <xsl:otherwise><xsl:value-of select="$fig-count+1"/></xsl:otherwise>
157 </xsl:choose>
158</xsl:variable>
159 <xsl:choose>
160 <xsl:when test="*[contains(@class,' topic/title ')]">
161 <fo:block><fo:inline font-weight="bold">
162 <xsl:call-template name="getString">
163 <xsl:with-param name="stringName" select="'Figure'"/>
164 </xsl:call-template><xsl:text> </xsl:text><xsl:value-of select="$fig-count-actual"/>.<xsl:text> </xsl:text>
165 <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="exhibittitle"/>
166 </fo:inline>
167 <xsl:if test="desc">
168 <xsl:text>. </xsl:text><xsl:apply-templates select="*[contains(@class,' topic/desc ')]" mode="exhibitdesc"/>
169 </xsl:if>
170 </fo:block>
171 </xsl:when>
172 <xsl:when test="*[contains(@class, ' topic/desc ')]">
173 <fo:block>****<xsl:value-of select="*[contains(@class,' topic/desc ')]"/></fo:block>
174 </xsl:when>
175 </xsl:choose>
176</xsl:template>
177
178
179
180<!-- ======== NAMED TEMPLATES for labels and titles related to topic structures ======== -->
181
182<xsl:template name="get-title"><!-- get fully-processed title content by whatever mechanism -->
183 <!-- insert anchor for PDF bookmark, using id attribute of topic element if id exists,
184 otherwise, generate it base on the topic element -->
185 <!-- inserting the anchor here ensures that it is on the same page as the topic title, not the page before -->
186 <xsl:choose>
187 <xsl:when test="parent::*/@id">
188 <xsl:apply-templates select="parent::*/@id"/>
189 </xsl:when>
190 <!-- only generate id for topic/title -->
191 <xsl:when test="parent::*[contains(@class, ' topic/topic ')]">
192 <fo:inline id="{generate-id(parent::*)}"></fo:inline>
193 </xsl:when>
194 <xsl:otherwise/>
195 </xsl:choose>
196 <xsl:choose>
197 <!-- add keycol here once implemented -->
198 <xsl:when test="@spectitle">
199 <xsl:value-of select="@spectitle"/>
200 </xsl:when>
201 <xsl:otherwise>
202 <xsl:apply-templates/> <!-- select="title|*[contains(@class,' topic/title ')]"/-->
203 </xsl:otherwise>
204 </xsl:choose>
205</xsl:template>
206
207<xsl:template name="get-sect-heading">
208 <xsl:choose>
209 <!-- replace with keyref once implemented -->
210 <xsl:when test="@spectitle">
211 <xsl:value-of select="@spectitle"/>
212 </xsl:when>
213 <xsl:otherwise>
214 <xsl:apply-templates select="title"/>
215 </xsl:otherwise>
216 </xsl:choose>
217</xsl:template>
218
219
220<xsl:template name="sect-heading">
221 <xsl:param name="deftitle" select="."/> <!-- get param by reference -->
222 <xsl:variable name="heading">
223 <xsl:choose>
224 <xsl:when test="*[contains(@class,' topic/title ')]">
225 <xsl:value-of select="*[contains(@class,' topic/title ')]"/>
226 </xsl:when>
227 <xsl:when test="@spectitle">
228 <xsl:value-of select="@spectitle"/>
229 </xsl:when>
230 <xsl:otherwise/>
231 </xsl:choose>
232 </xsl:variable>
233
234 <!-- based on graceful defaults, build an appropriate section-level heading -->
235 <xsl:choose>
236 <xsl:when test="not($heading='')">
237 <xsl:if test="normalize-space($heading)=''">
238 <!-- hack: a title with whitespace ALWAYS overrides as null -->
239 <!--xsl:comment>no heading</xsl:comment-->
240 </xsl:if>
241 <!--xsl:call-template name="proc-ing"/--><xsl:value-of select="$heading"/>
242 </xsl:when>
243 <xsl:when test="$deftitle">
244 <xsl:value-of select="$deftitle"/>
245 </xsl:when>
246 <xsl:otherwise><!-- no heading title, output section starting with a break --></xsl:otherwise>
247 </xsl:choose>
248</xsl:template>
249
250
251</xsl:stylesheet>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette