~ubuntu-branches/ubuntu/lucid/dblatex/lucid

« back to all changes in this revision

Viewing changes to xsl/sections.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Hoenen
  • Date: 2006-05-15 19:59:06 UTC
  • Revision ID: james.westby@ubuntu.com-20060515195906-jg9x08tsfbi35m2x
Tags: upstream-0.1.9
ImportĀ upstreamĀ versionĀ 0.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0'?>
 
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
 
3
 
 
4
<!--############################################################################
 
5
    XSLT Stylesheet DocBook -> LaTeX 
 
6
    ############################################################################ -->
 
7
 
 
8
<xsl:template match="sect1|sect2|sect3|sect4|sect5">
 
9
  <xsl:call-template name="element.and.label"/>
 
10
  <xsl:apply-templates/>
 
11
</xsl:template>
 
12
 
 
13
<xsl:template match="sect1/title"/>
 
14
<xsl:template match="sect2/title"/>
 
15
<xsl:template match="sect3/title"/>
 
16
<xsl:template match="sect4/title"/>
 
17
<xsl:template match="sect5/title"/>
 
18
 
 
19
<xsl:template name="map.sect.level">
 
20
  <xsl:param name="level" select="''"/>
 
21
  <xsl:param name="name" select="''"/>
 
22
  <xsl:param name="num" select="'1'"/>
 
23
  <xsl:text>&#10;</xsl:text>
 
24
  <xsl:choose>
 
25
  <xsl:when test="$level &lt; 6">
 
26
    <xsl:choose>
 
27
      <xsl:when test='$level=1'>\section</xsl:when>
 
28
      <xsl:when test='$level=2'>\subsection</xsl:when>
 
29
      <xsl:when test='$level=3'>\subsubsection</xsl:when>
 
30
      <xsl:when test='$level=4'>\paragraph</xsl:when>
 
31
      <xsl:when test='$level=5'>\subparagraph</xsl:when>
 
32
      <!-- rare case -->
 
33
      <xsl:when test='$level=0'>\chapter</xsl:when>
 
34
    </xsl:choose>
 
35
  </xsl:when>
 
36
  <xsl:when test="$name!=''">
 
37
    <xsl:choose>
 
38
      <xsl:when test="$name='sect1'">\section</xsl:when>
 
39
      <xsl:when test="$name='sect2'">\subsection</xsl:when>
 
40
      <xsl:when test="$name='sect3'">\subsubsection</xsl:when>
 
41
      <xsl:when test="$name='sect4'">\paragraph</xsl:when>
 
42
      <xsl:when test="$name='sect5'">\subparagraph</xsl:when>
 
43
    </xsl:choose>
 
44
  </xsl:when>
 
45
  <xsl:otherwise>
 
46
    <xsl:message>*** section level &gt; 6 not well supported</xsl:message> 
 
47
    <xsl:text>\subparagraph</xsl:text>
 
48
  </xsl:otherwise>
 
49
  </xsl:choose>
 
50
  <xsl:choose>
 
51
  <xsl:when test="$num = '0'">
 
52
    <xsl:text>*</xsl:text>
 
53
  </xsl:when>
 
54
  <xsl:when test="ancestor::preface|ancestor::colophon|
 
55
                  ancestor::dedication|ancestor::partintro|
 
56
                  ancestor::glossary|ancestor::qandaset">
 
57
    <xsl:text>*</xsl:text>
 
58
  </xsl:when>
 
59
  </xsl:choose>
 
60
</xsl:template>
 
61
 
 
62
<xsl:template match="section">
 
63
  <xsl:variable name="min">
 
64
    <xsl:choose>
 
65
    <xsl:when test="ancestor::appendix and ancestor::article">
 
66
      <xsl:value-of select="'2'"/>
 
67
    </xsl:when>
 
68
    <xsl:otherwise>
 
69
      <xsl:value-of select="'1'"/>
 
70
    </xsl:otherwise>
 
71
    </xsl:choose>
 
72
  </xsl:variable>
 
73
  <xsl:call-template name="map.sect.level">
 
74
    <xsl:with-param name="level" select="count(ancestor::section)+$min"/>
 
75
  </xsl:call-template>
 
76
  <xsl:call-template name="title.and.label"/>
 
77
  <xsl:apply-templates/>
 
78
</xsl:template>
 
79
 
 
80
<xsl:template name="get.sect.level">
 
81
  <xsl:param name="n" select="."/>
 
82
  <xsl:choose>
 
83
  <xsl:when test="$n/parent::section">
 
84
    <xsl:value-of select="count($n/ancestor::section)+1"/>
 
85
  </xsl:when>
 
86
  <xsl:when test="$n/parent::chapter">1</xsl:when>
 
87
  <xsl:when test="$n/parent::article">1</xsl:when>
 
88
  <xsl:when test="$n/parent::sect1">2</xsl:when>
 
89
  <xsl:when test="$n/parent::sect2">3</xsl:when>
 
90
  <xsl:when test="$n/parent::sect3">4</xsl:when>
 
91
  <xsl:when test="$n/parent::sect4">5</xsl:when>
 
92
  <xsl:when test="$n/parent::sect5">6</xsl:when>
 
93
  <xsl:when test="$n/parent::reference">1</xsl:when>
 
94
  <xsl:when test="$n/parent::preface">1</xsl:when>
 
95
  <xsl:when test="$n/parent::simplesect">
 
96
    <xsl:variable name="l">
 
97
      <xsl:call-template name="get.sect.level">
 
98
        <xsl:with-param name="n" select="$n/parent::simplesect"/>
 
99
      </xsl:call-template>
 
100
    </xsl:variable>
 
101
    <xsl:value-of select="$l+1"/>
 
102
  </xsl:when>
 
103
  <xsl:when test="$n/parent::book">0</xsl:when>
 
104
  <xsl:when test="$n/parent::part">0</xsl:when>
 
105
  <xsl:otherwise>7</xsl:otherwise>
 
106
  </xsl:choose>
 
107
</xsl:template>
 
108
 
 
109
<xsl:template match="simplesect">
 
110
  <xsl:call-template name="map.sect.level">
 
111
    <xsl:with-param name="level">
 
112
      <xsl:call-template name="get.sect.level"/>
 
113
    </xsl:with-param>
 
114
  </xsl:call-template>
 
115
  <xsl:call-template name="title.and.label"/>
 
116
  <xsl:apply-templates/>
 
117
</xsl:template>
 
118
 
 
119
<xsl:template match="section/title"/>
 
120
<xsl:template match="simplesect/title"/>
 
121
 
 
122
<xsl:template match="sectioninfo"/>
 
123
<xsl:template match="sect1info"/>
 
124
<xsl:template match="sect2info"/>
 
125
<xsl:template match="sect3info"/>
 
126
<xsl:template match="sect4info"/>
 
127
<xsl:template match="sect5info"/>
 
128
 
 
129
<xsl:template match="titleabbrev"/>
 
130
 
 
131
</xsl:stylesheet>