| 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="mapheading"/> |
| 10 |
<xsl:apply-templates/> |
| 11 |
</xsl:template> |
| 12 |
|
| 13 |
<xsl:template match="sect1/title"/> |
| 14 |
<xsl:template match="sect1/subtitle"/> |
| 15 |
<xsl:template match="sect2/title"/> |
| 16 |
<xsl:template match="sect2/subtitle"/> |
| 17 |
<xsl:template match="sect3/title"/> |
| 18 |
<xsl:template match="sect3/subtitle"/> |
| 19 |
<xsl:template match="sect4/title"/> |
| 20 |
<xsl:template match="sect4/subtitle"/> |
| 21 |
<xsl:template match="sect5/title"/> |
| 22 |
<xsl:template match="sect5/subtitle"/> |
| 23 |
|
| 24 |
<xsl:template name="map.sect.level"> |
| 25 |
<xsl:param name="level" select="''"/> |
| 26 |
<xsl:param name="name" select="''"/> |
| 27 |
<xsl:param name="num" select="'1'"/> |
| 28 |
<xsl:param name="allnum" select="'0'"/> |
| 29 |
<xsl:text> </xsl:text> |
| 30 |
<xsl:choose> |
| 31 |
<xsl:when test="$level < 6"> |
| 32 |
<xsl:choose> |
| 33 |
<xsl:when test='$level=1'>\section</xsl:when> |
| 34 |
<xsl:when test='$level=2'>\subsection</xsl:when> |
| 35 |
<xsl:when test='$level=3'>\subsubsection</xsl:when> |
| 36 |
<xsl:when test='$level=4'>\paragraph</xsl:when> |
| 37 |
<xsl:when test='$level=5'>\subparagraph</xsl:when> |
| 38 |
<!-- rare case --> |
| 39 |
<xsl:when test='$level=0'>\chapter</xsl:when> |
| 40 |
<xsl:when test='$level=-1'>\part</xsl:when> |
| 41 |
</xsl:choose> |
| 42 |
</xsl:when> |
| 43 |
<xsl:when test="$name!=''"> |
| 44 |
<xsl:choose> |
| 45 |
<xsl:when test="$name='sect1'">\section</xsl:when> |
| 46 |
<xsl:when test="$name='sect2'">\subsection</xsl:when> |
| 47 |
<xsl:when test="$name='sect3'">\subsubsection</xsl:when> |
| 48 |
<xsl:when test="$name='sect4'">\paragraph</xsl:when> |
| 49 |
<xsl:when test="$name='sect5'">\subparagraph</xsl:when> |
| 50 |
</xsl:choose> |
| 51 |
</xsl:when> |
| 52 |
<xsl:otherwise> |
| 53 |
<xsl:message> |
| 54 |
<xsl:text>Section level > 6 not well supported for </xsl:text> |
| 55 |
<xsl:value-of select="local-name(.)"/> |
| 56 |
<xsl:if test="@id|@xml:id"> |
| 57 |
<xsl:text>(id=</xsl:text> |
| 58 |
<xsl:value-of select="(@id|@xml:id)[1]"/> |
| 59 |
<xsl:text>)</xsl:text> |
| 60 |
</xsl:if> |
| 61 |
</xsl:message> |
| 62 |
<xsl:text>\subparagraph</xsl:text> |
| 63 |
</xsl:otherwise> |
| 64 |
</xsl:choose> |
| 65 |
<xsl:choose> |
| 66 |
<xsl:when test="$allnum = '1'"/> |
| 67 |
<xsl:when test="$num = '0'"> |
| 68 |
<xsl:text>*</xsl:text> |
| 69 |
</xsl:when> |
| 70 |
<xsl:when test="ancestor::preface|ancestor::colophon| |
| 71 |
ancestor::dedication|ancestor::partintro| |
| 72 |
ancestor::glossary|ancestor::qandaset"> |
| 73 |
<xsl:text>*</xsl:text> |
| 74 |
</xsl:when> |
| 75 |
</xsl:choose> |
| 76 |
</xsl:template> |
| 77 |
|
| 78 |
<xsl:template match="section"> |
| 79 |
<xsl:variable name="min"> |
| 80 |
<xsl:choose> |
| 81 |
<xsl:when test="ancestor::appendix and ancestor::article"> |
| 82 |
<xsl:value-of select="'2'"/> |
| 83 |
</xsl:when> |
| 84 |
<xsl:otherwise> |
| 85 |
<xsl:value-of select="'1'"/> |
| 86 |
</xsl:otherwise> |
| 87 |
</xsl:choose> |
| 88 |
</xsl:variable> |
| 89 |
<xsl:call-template name="makeheading"> |
| 90 |
<xsl:with-param name="level" select="count(ancestor::section)+$min"/> |
| 91 |
</xsl:call-template> |
| 92 |
<xsl:apply-templates/> |
| 93 |
</xsl:template> |
| 94 |
|
| 95 |
<xsl:template name="get.sect.level"> |
| 96 |
<xsl:param name="n" select="."/> |
| 97 |
<xsl:choose> |
| 98 |
<xsl:when test="$n/parent::section"> |
| 99 |
<xsl:value-of select="count($n/ancestor::section)+1"/> |
| 100 |
</xsl:when> |
| 101 |
<xsl:when test="$n/parent::chapter">1</xsl:when> |
| 102 |
<xsl:when test="$n/parent::article">1</xsl:when> |
| 103 |
<xsl:when test="$n/parent::sect1">2</xsl:when> |
| 104 |
<xsl:when test="$n/parent::sect2">3</xsl:when> |
| 105 |
<xsl:when test="$n/parent::sect3">4</xsl:when> |
| 106 |
<xsl:when test="$n/parent::sect4">5</xsl:when> |
| 107 |
<xsl:when test="$n/parent::sect5">6</xsl:when> |
| 108 |
<xsl:when test="$n/parent::reference">1</xsl:when> |
| 109 |
<xsl:when test="$n/parent::preface">1</xsl:when> |
| 110 |
<xsl:when test="$n/parent::simplesect or |
| 111 |
$n/parent::refentry"> |
| 112 |
<xsl:variable name="l"> |
| 113 |
<xsl:call-template name="get.sect.level"> |
| 114 |
<xsl:with-param name="n" select="$n/parent::*"/> |
| 115 |
</xsl:call-template> |
| 116 |
</xsl:variable> |
| 117 |
<xsl:value-of select="$l+1"/> |
| 118 |
</xsl:when> |
| 119 |
<xsl:when test="$n/parent::book"> |
| 120 |
<xsl:choose> |
| 121 |
<xsl:when test="preceding-sibling::part or |
| 122 |
following-sibling::part">-1</xsl:when> |
| 123 |
<xsl:otherwise>0</xsl:otherwise> |
| 124 |
</xsl:choose> |
| 125 |
</xsl:when> |
| 126 |
<xsl:when test="$n/parent::part">0</xsl:when> |
| 127 |
<xsl:when test="$n/parent::appendix"> |
| 128 |
<xsl:choose> |
| 129 |
<xsl:when test="$n/ancestor::book">1</xsl:when> |
| 130 |
<xsl:otherwise>2</xsl:otherwise> |
| 131 |
</xsl:choose> |
| 132 |
</xsl:when> |
| 133 |
<xsl:otherwise>7</xsl:otherwise> |
| 134 |
</xsl:choose> |
| 135 |
</xsl:template> |
| 136 |
|
| 137 |
<xsl:template match="simplesect"> |
| 138 |
<xsl:call-template name="makeheading"> |
| 139 |
<xsl:with-param name="level"> |
| 140 |
<xsl:call-template name="get.sect.level"/> |
| 141 |
</xsl:with-param> |
| 142 |
</xsl:call-template> |
| 143 |
<xsl:apply-templates/> |
| 144 |
</xsl:template> |
| 145 |
|
| 146 |
<xsl:template match="section/title"/> |
| 147 |
<xsl:template match="simplesect/title"/> |
| 148 |
|
| 149 |
<xsl:template match="sectioninfo |
| 150 |
|sect1info |
| 151 |
|sect2info |
| 152 |
|sect3info |
| 153 |
|sect4info |
| 154 |
|sect5info"> |
| 155 |
<xsl:apply-templates select="itermset"/> |
| 156 |
</xsl:template> |
| 157 |
|
| 158 |
<xsl:template match="titleabbrev"/> |
| 159 |
|
| 160 |
</xsl:stylesheet> |