-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcustomization.xsl
71 lines (65 loc) · 3.65 KB
/
customization.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="ditaarch opentopic e" version="2.0"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
xmlns:e="org.dita.pdf2.topic.numbering" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
When this option is enabled the topic's number will be presented before the topics's title.
-->
<xsl:param name="numbers-before-title" select="'no'"/>
<!--
Specifies the depth of the topics that will be numbered when the 'numbers-before-title' option is enabled.
-->
<xsl:param name="numbers-before-title-depth" select="3"/>
<xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')][$numbers-before-title = 'yes']"
mode="getTitle">
<xsl:variable name="topic"
select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]"/>
<xsl:variable name="id" select="$topic/@id"/>
<xsl:variable name="mapTopics" select="key('map-id', $id)"/>
<!--
Do not generate numbers for first level chapters, appendix topics and parts.
-->
<xsl:if test="not(contains($mapTopics[1]/@class, ' bookmap/chapter '))
and not(contains($mapTopics[1]/@class, ' bookmap/appendix '))
and not(contains($mapTopics[1]/@class, ' bookmap/part '))">
<fo:inline>
<xsl:for-each select="$mapTopics[1]">
<xsl:variable name="depth"
select="count(ancestor-or-self::*[contains(@class, ' map/topicref')])"/>
<xsl:choose>
<xsl:when test="parent::opentopic:map and contains(@class, ' bookmap/bookmap ')"/>
<!-- Do not add numbers for fontmatter or backmatter topics -->
<xsl:when
test="
ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ') or
contains(@class, ' bookmap/backmatter ')]"/>
<!-- Appendix topics -->
<xsl:when
test="
ancestor-or-self::*[contains(@class, ' bookmap/appendix ')] and
$depth lt (xs:integer($numbers-before-title-depth) + 1)">
<!--<xsl:number
count="
*[contains(@class, ' map/topicref ')]
[ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]]"
format="A.1.1" level="multiple"/>-->
</xsl:when>
<!-- Normal topics -->
<xsl:when test="$depth lt (xs:integer($numbers-before-title-depth) + 1)">
<xsl:number
count="
*[contains(@class, ' map/topicref ')]
[not(ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ')])]"
format="1.1" level="multiple"/>
<xsl:value-of select="' '"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</fo:inline>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>