Documentation Tools
- Timestamp:
- 02/19/08 17:21:15 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/modules/modules/docbook-simple/v1.1/xhtml-strict/1.0/main.xsl
r269 r270 2 2 <!DOCTYPE xsl:stylesheet [ 3 3 <!ENTITY nbsp " "> 4 <!ENTITY sect "§">5 4 ]> 6 5 … … 9 8 xmlns="http://www.w3.org/1999/xhtml"> 10 9 10 <!-- 11 Main interface. 12 13 $Id$ 14 --> 15 16 17 <!-- 18 TODO perhaps each imported stylesheet should only contain mode="" attributes? 19 Is that too restrictive? 20 --> 21 <xsl:import href="toc.xsl"/> 22 <xsl:import href="title.xsl"/> 23 11 24 <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 12 25 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 13 26 encoding="utf-8" indent="yes"/> 14 27 15 <!-- TODO to be done in the framework -->28 <!-- TODO to be done in the framework; perhaps the python can automatically include this --> 16 29 <!-- 17 30 <xsl:template match="*"> … … 82 95 TODO: attributes for everything. e.g. @lang, @revisionflag etc 83 96 97 TODO: normalise space. 98 84 99 --> 85 100 … … 116 131 117 132 <head> 118 <xsl:choose> 119 <xsl:when test="title"> 120 <title> 121 <xsl:apply-templates select="title"/> 122 </title> 123 </xsl:when> 124 125 <xsl:when test="articleinfo/title"> 126 <title> 127 <xsl:apply-templates select="articleinfo/title"/> 128 </title> 129 </xsl:when> 130 </xsl:choose> 133 <xsl:call-template name="title-head"/> 131 134 132 135 <xsl:if test="$option-stylesheet"> … … 140 143 141 144 <body> 142 <xsl:choose> 143 <xsl:when test="articleinfo/title"> 144 <h1> 145 <xsl:apply-templates select="articleinfo/title"/> 146 </h1> 147 </xsl:when> 148 149 <xsl:when test="title"> 150 <h1> 151 <xsl:apply-templates select="title"/> 152 </h1> 153 </xsl:when> 154 </xsl:choose> 145 <xsl:call-template name="title-body"/> 155 146 156 147 <xsl:apply-templates select="articleinfo/author"/> … … 160 151 <xsl:apply-templates select="articleinfo/abstract"/> 161 152 162 <xsl:if test="section|appendix|bibliography"> 163 <div class="toc"> 164 <h2> 165 <xsl:text>Table of Contents</xsl:text> 166 </h2> 167 168 <ol> 169 <xsl:apply-templates select="section|appendix|bibliography" mode="toc"/> 170 </ol> 171 </div> 172 </xsl:if> 153 <xsl:call-template name="toc"/> 173 154 174 155 <xsl:apply-templates select="section|appendix|bibliography … … 180 161 </xsl:template> 181 162 182 <!--183 Produce a linkable id from a given non-root <title> tag.184 This is suitable for use as a HTML anchor.185 -->186 <xsl:template name="link-title">187 <xsl:choose>188 <xsl:when test="ancestor::bibliography">189 <xsl:text>bib-</xsl:text>190 <xsl:number count="bibliography" level="single" format="1"/>191 </xsl:when>192 193 <xsl:when test="ancestor::appendix">194 <!-- No prefix -->195 </xsl:when>196 197 <xsl:when test="ancestor::section">198 <!-- TODO is § legal for # links in HTML? -->199 <xsl:text>§</xsl:text>200 </xsl:when>201 202 <xsl:otherwise>203 <xsl:message terminate="yes">204 <xsl:text>Unrecognised link title ancestor</xsl:text>205 </xsl:message>206 </xsl:otherwise>207 </xsl:choose>208 209 <xsl:call-template name="number-title"/>210 </xsl:template>211 212 <!--213 Output a number-title prefix, for numbering headings of sections.214 Outputs nothing if the output-titlenumber option is false.215 216 Call from inside a title.217 -->218 <xsl:template name="titlenumber-title">219 <xsl:if test="$option-titlenumber">220 <xsl:call-template name="number-title"/>221 <xsl:text> </xsl:text>222 </xsl:if>223 </xsl:template>224 225 <!--226 Enumerate a title (not article/title). No trailing space.227 -->228 <xsl:template name="number-title">229 <xsl:choose>230 <xsl:when test="ancestor::appendix">231 <xsl:number count="appendix" level="single" format="A"/>232 233 <xsl:if test="ancestor-or-self::section">234 <xsl:text>.</xsl:text>235 </xsl:if>236 </xsl:when>237 238 <xsl:when test="ancestor::bibliography">239 <!-- We do not enumerate bibliographies -->240 </xsl:when>241 </xsl:choose>242 243 <xsl:number count="section" level="multiple" format="1"/>244 </xsl:template>245 246 <xsl:template match="section|appendix|bibliography" mode="toc">247 <xsl:apply-templates select="title" mode="toc"/>248 249 <ol>250 <xsl:apply-templates select="section/title" mode="toc"/>251 </ol>252 </xsl:template>253 254 <xsl:template match="section/title|bibliography/title|appendix/title" mode="toc">255 <li style="list-style-type: none;">256 <xsl:call-template name="titlenumber-title"/>257 258 <a>259 <xsl:attribute name="href">260 <xsl:text>#</xsl:text>261 <xsl:call-template name="link-title"/>262 </xsl:attribute>263 264 <xsl:apply-templates/>265 </a>266 </li>267 </xsl:template>268 269 163 <xsl:template match="author"> 270 164 <div class="author"> … … 304 198 </xsl:template> 305 199 306 <xsl:template match="title">307 <a>308 <xsl:attribute name="name">309 <xsl:call-template name="link-title"/>310 </xsl:attribute>311 </a>312 313 <xsl:apply-templates/>314 </xsl:template>315 316 <!--317 Generate no link for the main article title.318 -->319 <xsl:template match="article/title|articleinfo/title">320 <xsl:apply-templates/>321 </xsl:template>322 323 200 <xsl:template match="section"> 324 201 <div class="section"> … … 328 205 <xsl:apply-templates select="title"/> 329 206 </h2> 207 208 <xsl:call-template name="toc"/> 330 209 331 210 <xsl:apply-templates select="*[name() != 'title']"/> … … 342 221 </h2> 343 222 223 <xsl:call-template name="toc"/> 224 344 225 <xsl:apply-templates select="*[name() != 'title']"/> 345 226 </div>
Note: See TracChangeset
for help on using the changeset viewer.