1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version='1.0'> 4 5<!-- ******************************************************************** 6 $Id: formal.xsl,v 1.22 2006/05/02 07:00:01 bobstayton Exp $ 7 ******************************************************************** 8 9 This file is part of the XSL DocBook Stylesheet distribution. 10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright 11 and other information. 12 13 ******************************************************************** --> 14 15<xsl:param name="formal.object.break.after">1</xsl:param> 16 17<xsl:template name="formal.object"> 18 <xsl:param name="placement" select="'before'"/> 19 <xsl:param name="class" select="local-name(.)"/> 20 21 <xsl:call-template name="id.warning"/> 22 23 <xsl:variable name="content"> 24 <div class="{$class}"> 25 <xsl:call-template name="anchor"> 26 <xsl:with-param name="conditional" select="0"/> 27 </xsl:call-template> 28 29 <xsl:choose> 30 <xsl:when test="$placement = 'before'"> 31 <xsl:call-template name="formal.object.heading"/> 32 <div class="{$class}-contents"> 33 <xsl:apply-templates/> 34 </div> 35 <!-- HACK: This doesn't belong inside formal.object; it 36 should be done by the table template, but I want 37 the link to be inside the DIV, so... --> 38 <xsl:if test="local-name(.) = 'table'"> 39 <xsl:call-template name="table.longdesc"/> 40 </xsl:if> 41 42 <xsl:if test="$spacing.paras != 0"><p/></xsl:if> 43 </xsl:when> 44 <xsl:otherwise> 45 <xsl:if test="$spacing.paras != 0"><p/></xsl:if> 46 <div class="{$class}-contents"><xsl:apply-templates/></div> 47 <!-- HACK: This doesn't belong inside formal.object; it 48 should be done by the table template, but I want 49 the link to be inside the DIV, so... --> 50 <xsl:if test="local-name(.) = 'table'"> 51 <xsl:call-template name="table.longdesc"/> 52 </xsl:if> 53 54 <xsl:call-template name="formal.object.heading"/> 55 </xsl:otherwise> 56 </xsl:choose> 57 </div> 58 <xsl:if test="not($formal.object.break.after = '0')"> 59 <br class="{$class}-break"/> 60 </xsl:if> 61 </xsl:variable> 62 63 <xsl:variable name="floatstyle"> 64 <xsl:call-template name="floatstyle"/> 65 </xsl:variable> 66 67 <xsl:choose> 68 <xsl:when test="$floatstyle != ''"> 69 <xsl:call-template name="floater"> 70 <xsl:with-param name="class"><xsl:value-of 71 select="$class"/>-float</xsl:with-param> 72 <xsl:with-param name="floatstyle" select="$floatstyle"/> 73 <xsl:with-param name="content" select="$content"/> 74 </xsl:call-template> 75 </xsl:when> 76 <xsl:otherwise> 77 <xsl:copy-of select="$content"/> 78 </xsl:otherwise> 79 </xsl:choose> 80 81</xsl:template> 82 83<xsl:template name="formal.object.heading"> 84 <xsl:param name="object" select="."/> 85 <xsl:param name="title"> 86 <xsl:apply-templates select="$object" mode="object.title.markup"> 87 <xsl:with-param name="allow-anchors" select="1"/> 88 </xsl:apply-templates> 89 </xsl:param> 90 91 <p class="title"> 92 <b> 93 <xsl:copy-of select="$title"/> 94 </b> 95 </p> 96</xsl:template> 97 98<xsl:template name="informal.object"> 99 <xsl:param name="class" select="local-name(.)"/> 100 101 <xsl:variable name="content"> 102 <div class="{$class}"> 103 <xsl:if test="$spacing.paras != 0"><p/></xsl:if> 104 <xsl:call-template name="anchor"/> 105 <xsl:apply-templates/> 106 107 <!-- HACK: This doesn't belong inside formal.object; it 108 should be done by the table template, but I want 109 the link to be inside the DIV, so... --> 110 <xsl:if test="local-name(.) = 'informaltable'"> 111 <xsl:call-template name="table.longdesc"/> 112 </xsl:if> 113 114 <xsl:if test="$spacing.paras != 0"><p/></xsl:if> 115 </div> 116 </xsl:variable> 117 118 <xsl:variable name="floatstyle"> 119 <xsl:call-template name="floatstyle"/> 120 </xsl:variable> 121 122 <xsl:choose> 123 <xsl:when test="$floatstyle != ''"> 124 <xsl:call-template name="floater"> 125 <xsl:with-param name="class"><xsl:value-of 126 select="$class"/>-float</xsl:with-param> 127 <xsl:with-param name="floatstyle" select="$floatstyle"/> 128 <xsl:with-param name="content" select="$content"/> 129 </xsl:call-template> 130 </xsl:when> 131 <xsl:otherwise> 132 <xsl:copy-of select="$content"/> 133 </xsl:otherwise> 134 </xsl:choose> 135 136</xsl:template> 137 138<xsl:template name="semiformal.object"> 139 <xsl:param name="placement" select="'before'"/> 140 <xsl:param name="class" select="local-name(.)"/> 141 142 <xsl:choose> 143 <xsl:when test="title"> 144 <xsl:call-template name="formal.object"> 145 <xsl:with-param name="placement" select="$placement"/> 146 <xsl:with-param name="class" select="$class"/> 147 </xsl:call-template> 148 </xsl:when> 149 <xsl:otherwise> 150 <xsl:call-template name="informal.object"> 151 <xsl:with-param name="class" select="$class"/> 152 </xsl:call-template> 153 </xsl:otherwise> 154 </xsl:choose> 155</xsl:template> 156 157<xsl:template match="figure"> 158 <xsl:variable name="param.placement" 159 select="substring-after(normalize-space($formal.title.placement), 160 concat(local-name(.), ' '))"/> 161 162 <xsl:variable name="placement"> 163 <xsl:choose> 164 <xsl:when test="contains($param.placement, ' ')"> 165 <xsl:value-of select="substring-before($param.placement, ' ')"/> 166 </xsl:when> 167 <xsl:when test="$param.placement = ''">before</xsl:when> 168 <xsl:otherwise> 169 <xsl:value-of select="$param.placement"/> 170 </xsl:otherwise> 171 </xsl:choose> 172 </xsl:variable> 173 174 <xsl:call-template name="formal.object"> 175 <xsl:with-param name="placement" select="$placement"/> 176 </xsl:call-template> 177 178</xsl:template> 179 180<xsl:template match="table"> 181 <xsl:choose> 182 <xsl:when test="tgroup|mediaobject|graphic"> 183 <xsl:call-template name="calsTable"/> 184 </xsl:when> 185 <xsl:otherwise> 186 <xsl:copy> 187 <xsl:copy-of select="@*"/> 188 <xsl:if test="not(@id)"> 189 <xsl:attribute name="id"> 190 <xsl:call-template name="object.id"/> 191 </xsl:attribute> 192 </xsl:if> 193 <xsl:call-template name="htmlTable"/> 194 </xsl:copy> 195 </xsl:otherwise> 196 </xsl:choose> 197</xsl:template> 198 199<xsl:template name="calsTable"> 200 <xsl:if test="tgroup/tbody/tr 201 |tgroup/thead/tr 202 |tgroup/tfoot/tr"> 203 <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message> 204 </xsl:if> 205 206 <xsl:variable name="param.placement" 207 select="substring-after(normalize-space($formal.title.placement), 208 concat(local-name(.), ' '))"/> 209 210 <xsl:variable name="placement"> 211 <xsl:choose> 212 <xsl:when test="contains($param.placement, ' ')"> 213 <xsl:value-of select="substring-before($param.placement, ' ')"/> 214 </xsl:when> 215 <xsl:when test="$param.placement = ''">before</xsl:when> 216 <xsl:otherwise> 217 <xsl:value-of select="$param.placement"/> 218 </xsl:otherwise> 219 </xsl:choose> 220 </xsl:variable> 221 222 <xsl:call-template name="formal.object"> 223 <xsl:with-param name="placement" select="$placement"/> 224 <xsl:with-param name="class"> 225 <xsl:choose> 226 <xsl:when test="@tabstyle"> 227 <!-- hack, this will only ever occur on table, not example --> 228 <xsl:value-of select="@tabstyle"/> 229 </xsl:when> 230 <xsl:otherwise> 231 <xsl:value-of select="local-name(.)"/> 232 </xsl:otherwise> 233 </xsl:choose> 234 </xsl:with-param> 235 </xsl:call-template> 236</xsl:template> 237 238<xsl:template name="htmlTable"> 239 <xsl:if test="tgroup/tbody/row 240 |tgroup/thead/row 241 |tgroup/tfoot/row"> 242 <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message> 243 </xsl:if> 244 245 <xsl:apply-templates mode="htmlTable"/> 246</xsl:template> 247 248<xsl:template match="example"> 249 <xsl:variable name="param.placement" 250 select="substring-after(normalize-space($formal.title.placement), 251 concat(local-name(.), ' '))"/> 252 253 <xsl:variable name="placement"> 254 <xsl:choose> 255 <xsl:when test="contains($param.placement, ' ')"> 256 <xsl:value-of select="substring-before($param.placement, ' ')"/> 257 </xsl:when> 258 <xsl:when test="$param.placement = ''">before</xsl:when> 259 <xsl:otherwise> 260 <xsl:value-of select="$param.placement"/> 261 </xsl:otherwise> 262 </xsl:choose> 263 </xsl:variable> 264 265 <xsl:call-template name="formal.object"> 266 <xsl:with-param name="placement" select="$placement"/> 267 </xsl:call-template> 268 269</xsl:template> 270 271<xsl:template match="equation"> 272 <xsl:variable name="param.placement" 273 select="substring-after(normalize-space($formal.title.placement), 274 concat(local-name(.), ' '))"/> 275 276 <xsl:variable name="placement"> 277 <xsl:choose> 278 <xsl:when test="contains($param.placement, ' ')"> 279 <xsl:value-of select="substring-before($param.placement, ' ')"/> 280 </xsl:when> 281 <xsl:when test="$param.placement = ''">before</xsl:when> 282 <xsl:otherwise> 283 <xsl:value-of select="$param.placement"/> 284 </xsl:otherwise> 285 </xsl:choose> 286 </xsl:variable> 287 288 <xsl:call-template name="formal.object"> 289 <xsl:with-param name="placement" select="$placement"/> 290 </xsl:call-template> 291 292</xsl:template> 293 294<xsl:template match="figure/title"></xsl:template> 295<xsl:template match="figure/titleabbrev"></xsl:template> 296<xsl:template match="table/title"></xsl:template> 297<xsl:template match="table/titleabbrev"></xsl:template> 298<xsl:template match="table/textobject"></xsl:template> 299<xsl:template match="example/title"></xsl:template> 300<xsl:template match="example/titleabbrev"></xsl:template> 301<xsl:template match="equation/title"></xsl:template> 302<xsl:template match="equation/titleabbrev"></xsl:template> 303 304<xsl:template match="informalfigure"> 305 <xsl:call-template name="informal.object"/> 306</xsl:template> 307 308<xsl:template match="informalexample"> 309 <xsl:call-template name="informal.object"/> 310</xsl:template> 311 312<xsl:template match="informaltable"> 313 <xsl:choose> 314 <xsl:when test="tgroup|mediaobject|graphic"> 315 <xsl:call-template name="informal.object"> 316 <xsl:with-param name="class"> 317 <xsl:choose> 318 <xsl:when test="@tabstyle"> 319 <xsl:value-of select="@tabstyle"/> 320 </xsl:when> 321 <xsl:otherwise> 322 <xsl:value-of select="local-name(.)"/> 323 </xsl:otherwise> 324 </xsl:choose> 325 </xsl:with-param> 326 </xsl:call-template> 327 </xsl:when> 328 <xsl:otherwise> 329 <table> 330 <xsl:copy-of select="@*"/> 331 <xsl:call-template name="htmlTable"/> 332 </table> 333 </xsl:otherwise> 334 </xsl:choose> 335</xsl:template> 336 337<xsl:template match="informaltable/textobject"></xsl:template> 338 339<xsl:template name="table.longdesc"> 340 <!-- HACK: This doesn't belong inside formal.objectt; it should be done by --> 341 <!-- the table template, but I want the link to be inside the DIV, so... --> 342 <xsl:variable name="longdesc.uri"> 343 <xsl:call-template name="longdesc.uri"> 344 <xsl:with-param name="mediaobject" select="."/> 345 </xsl:call-template> 346 </xsl:variable> 347 348 <xsl:variable name="irrelevant"> 349 <!-- write.longdesc returns the filename ... --> 350 <xsl:call-template name="write.longdesc"> 351 <xsl:with-param name="mediaobject" select="."/> 352 </xsl:call-template> 353 </xsl:variable> 354 355 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 356 and textobject[not(phrase)]"> 357 <xsl:call-template name="longdesc.link"> 358 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/> 359 </xsl:call-template> 360 </xsl:if> 361</xsl:template> 362 363<xsl:template match="informalequation"> 364 <xsl:call-template name="informal.object"/> 365</xsl:template> 366 367<xsl:template name="floatstyle"> 368 <xsl:if test="(@float and @float != '0') or @floatstyle != ''"> 369 <xsl:choose> 370 <xsl:when test="@floatstyle != ''"> 371 <xsl:value-of select="@floatstyle"/> 372 </xsl:when> 373 <xsl:when test="@float = '1'"> 374 <xsl:value-of select="$default.float.class"/> 375 </xsl:when> 376 <xsl:otherwise> 377 <xsl:value-of select="@float"/> 378 </xsl:otherwise> 379 </xsl:choose> 380 </xsl:if> 381</xsl:template> 382 383<xsl:template name="floater"> 384 <xsl:param name="content"/> 385 <xsl:param name="class" select="'float'"/> 386 <xsl:param name="floatstyle" select="'left'"/> 387 388 <div class="{$class}"> 389 <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'"> 390 <xsl:attribute name="style"> 391 <xsl:text>float: </xsl:text> 392 <xsl:value-of select="$floatstyle"/> 393 <xsl:text>;</xsl:text> 394 </xsl:attribute> 395 </xsl:if> 396 <xsl:copy-of select="$content"/> 397 </div> 398</xsl:template> 399 400</xsl:stylesheet> 401