| 1 | <?xml version='1.0'?>
|
|---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|---|
| 3 | xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
|---|
| 4 | version='1.0'>
|
|---|
| 5 |
|
|---|
| 6 | <!-- ********************************************************************
|
|---|
| 7 | $Id: qandaset.xsl,v 1.18 2005/06/27 22:09:15 bobstayton Exp $
|
|---|
| 8 | ********************************************************************
|
|---|
| 9 |
|
|---|
| 10 | This file is part of the XSL DocBook Stylesheet distribution.
|
|---|
| 11 | See ../README or http://nwalsh.com/docbook/xsl/ for copyright
|
|---|
| 12 | and other information.
|
|---|
| 13 |
|
|---|
| 14 | ******************************************************************** -->
|
|---|
| 15 |
|
|---|
| 16 | <!-- ==================================================================== -->
|
|---|
| 17 |
|
|---|
| 18 | <xsl:template match="qandaset">
|
|---|
| 19 | <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
|
|---|
| 20 |
|
|---|
| 21 | <xsl:variable name="label-width">
|
|---|
| 22 | <xsl:call-template name="dbfo-attribute">
|
|---|
| 23 | <xsl:with-param name="pis"
|
|---|
| 24 | select="processing-instruction('dbfo')"/>
|
|---|
| 25 | <xsl:with-param name="attribute" select="'label-width'"/>
|
|---|
| 26 | </xsl:call-template>
|
|---|
| 27 | </xsl:variable>
|
|---|
| 28 |
|
|---|
| 29 | <xsl:variable name="label-length">
|
|---|
| 30 | <xsl:choose>
|
|---|
| 31 | <xsl:when test="$label-width != ''">
|
|---|
| 32 | <xsl:value-of select="$label-width"/>
|
|---|
| 33 | </xsl:when>
|
|---|
| 34 | <xsl:when test="descendant::label">
|
|---|
| 35 | <xsl:call-template name="longest.term">
|
|---|
| 36 | <xsl:with-param name="terms" select="descendant::label"/>
|
|---|
| 37 | <xsl:with-param name="maxlength" select="20"/>
|
|---|
| 38 | </xsl:call-template>
|
|---|
| 39 | <xsl:text>em * 0.50</xsl:text>
|
|---|
| 40 | </xsl:when>
|
|---|
| 41 | <xsl:otherwise>2.5em</xsl:otherwise>
|
|---|
| 42 | </xsl:choose>
|
|---|
| 43 | </xsl:variable>
|
|---|
| 44 |
|
|---|
| 45 | <fo:block id="{$id}">
|
|---|
| 46 | <xsl:if test="blockinfo/title|info/title|title">
|
|---|
| 47 | <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
|
|---|
| 48 | </xsl:if>
|
|---|
| 49 |
|
|---|
| 50 | <xsl:apply-templates select="*[name(.) != 'title'
|
|---|
| 51 | and name(.) != 'titleabbrev'
|
|---|
| 52 | and name(.) != 'qandadiv'
|
|---|
| 53 | and name(.) != 'qandaentry']"/>
|
|---|
| 54 | <xsl:apply-templates select="qandadiv"/>
|
|---|
| 55 |
|
|---|
| 56 | <xsl:if test="qandaentry">
|
|---|
| 57 | <fo:list-block xsl:use-attribute-sets="list.block.spacing"
|
|---|
| 58 | provisional-label-separation="0.2em">
|
|---|
| 59 | <xsl:attribute name="provisional-distance-between-starts">
|
|---|
| 60 | <xsl:choose>
|
|---|
| 61 | <xsl:when test="$label-length != ''">
|
|---|
| 62 | <xsl:value-of select="$label-length"/>
|
|---|
| 63 | </xsl:when>
|
|---|
| 64 | <xsl:otherwise>2.5em</xsl:otherwise>
|
|---|
| 65 | </xsl:choose>
|
|---|
| 66 | </xsl:attribute>
|
|---|
| 67 | <xsl:apply-templates select="qandaentry"/>
|
|---|
| 68 | </fo:list-block>
|
|---|
| 69 | </xsl:if>
|
|---|
| 70 | </fo:block>
|
|---|
| 71 | </xsl:template>
|
|---|
| 72 |
|
|---|
| 73 | <xsl:template match="qandaset/blockinfo/title|qandset/info/title|qandaset/title">
|
|---|
| 74 | <xsl:variable name="enclsect" select="(ancestor::section
|
|---|
| 75 | | ancestor::simplesect
|
|---|
| 76 | | ancestor::sect5
|
|---|
| 77 | | ancestor::sect4
|
|---|
| 78 | | ancestor::sect3
|
|---|
| 79 | | ancestor::sect2
|
|---|
| 80 | | ancestor::sect1
|
|---|
| 81 | | ancestor::refsect3
|
|---|
| 82 | | ancestor::refsect2
|
|---|
| 83 | | ancestor::refsect1)[last()]"/>
|
|---|
| 84 | <xsl:variable name="sectlvl">
|
|---|
| 85 | <xsl:call-template name="section.level">
|
|---|
| 86 | <xsl:with-param name="node" select="$enclsect"/>
|
|---|
| 87 | </xsl:call-template>
|
|---|
| 88 | </xsl:variable>
|
|---|
| 89 |
|
|---|
| 90 | <xsl:call-template name="qanda.heading">
|
|---|
| 91 | <xsl:with-param name="level" select="$sectlvl + 1"/>
|
|---|
| 92 | <xsl:with-param name="marker" select="0"/>
|
|---|
| 93 | <xsl:with-param name="title">
|
|---|
| 94 | <xsl:apply-templates/>
|
|---|
| 95 | </xsl:with-param>
|
|---|
| 96 | </xsl:call-template>
|
|---|
| 97 | </xsl:template>
|
|---|
| 98 |
|
|---|
| 99 | <xsl:template match="qandaset/blockinfo">
|
|---|
| 100 | <!-- what should this template really do? -->
|
|---|
| 101 | <xsl:apply-templates select="legalnotice" mode="titlepage.mode"/>
|
|---|
| 102 | </xsl:template>
|
|---|
| 103 |
|
|---|
| 104 | <xsl:template match="qandadiv">
|
|---|
| 105 | <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
|
|---|
| 106 |
|
|---|
| 107 | <xsl:variable name="label-width">
|
|---|
| 108 | <xsl:call-template name="dbfo-attribute">
|
|---|
| 109 | <xsl:with-param name="pis"
|
|---|
| 110 | select="processing-instruction('dbfo')"/>
|
|---|
| 111 | <xsl:with-param name="attribute" select="'label-width'"/>
|
|---|
| 112 | </xsl:call-template>
|
|---|
| 113 | </xsl:variable>
|
|---|
| 114 |
|
|---|
| 115 | <xsl:variable name="label-length">
|
|---|
| 116 | <xsl:choose>
|
|---|
| 117 | <xsl:when test="$label-width != ''">
|
|---|
| 118 | <xsl:value-of select="$label-width"/>
|
|---|
| 119 | </xsl:when>
|
|---|
| 120 | <xsl:when test="descendant::label">
|
|---|
| 121 | <xsl:call-template name="longest.term">
|
|---|
| 122 | <xsl:with-param name="terms" select="descendant::label"/>
|
|---|
| 123 | <xsl:with-param name="maxlength" select="20"/>
|
|---|
| 124 | </xsl:call-template>
|
|---|
| 125 | <xsl:text>*0.6em</xsl:text>
|
|---|
| 126 | </xsl:when>
|
|---|
| 127 | <xsl:otherwise>2.5em</xsl:otherwise>
|
|---|
| 128 | </xsl:choose>
|
|---|
| 129 | </xsl:variable>
|
|---|
| 130 |
|
|---|
| 131 | <fo:block id="{$id}">
|
|---|
| 132 | <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
|
|---|
| 133 | <xsl:apply-templates select="*[name(.) != 'title'
|
|---|
| 134 | and name(.) != 'titleabbrev'
|
|---|
| 135 | and name(.) != 'qandadiv'
|
|---|
| 136 | and name(.) != 'qandaentry']"/>
|
|---|
| 137 | <fo:block>
|
|---|
| 138 | <xsl:apply-templates select="qandadiv"/>
|
|---|
| 139 |
|
|---|
| 140 | <xsl:if test="qandaentry">
|
|---|
| 141 | <fo:list-block xsl:use-attribute-sets="list.block.spacing"
|
|---|
| 142 | provisional-label-separation="0.2em">
|
|---|
| 143 | <xsl:attribute name="provisional-distance-between-starts">
|
|---|
| 144 | <xsl:choose>
|
|---|
| 145 | <xsl:when test="$label-length != ''">
|
|---|
| 146 | <xsl:value-of select="$label-length"/>
|
|---|
| 147 | </xsl:when>
|
|---|
| 148 | <xsl:otherwise>2.5em</xsl:otherwise>
|
|---|
| 149 | </xsl:choose>
|
|---|
| 150 | </xsl:attribute>
|
|---|
| 151 | <xsl:apply-templates select="qandaentry"/>
|
|---|
| 152 | </fo:list-block>
|
|---|
| 153 | </xsl:if>
|
|---|
| 154 | </fo:block>
|
|---|
| 155 | </fo:block>
|
|---|
| 156 | </xsl:template>
|
|---|
| 157 |
|
|---|
| 158 | <xsl:template match="qandadiv/blockinfo/title|qandadiv/info/title|qandadiv/title">
|
|---|
| 159 | <xsl:variable name="enclsect" select="(ancestor::section
|
|---|
| 160 | | ancestor::simplesect
|
|---|
| 161 | | ancestor::sect5
|
|---|
| 162 | | ancestor::sect4
|
|---|
| 163 | | ancestor::sect3
|
|---|
| 164 | | ancestor::sect2
|
|---|
| 165 | | ancestor::sect1
|
|---|
| 166 | | ancestor::refsect3
|
|---|
| 167 | | ancestor::refsect2
|
|---|
| 168 | | ancestor::refsect1)[last()]"/>
|
|---|
| 169 | <xsl:variable name="sectlvl">
|
|---|
| 170 | <xsl:call-template name="section.level">
|
|---|
| 171 | <xsl:with-param name="node" select="$enclsect"/>
|
|---|
| 172 | </xsl:call-template>
|
|---|
| 173 | </xsl:variable>
|
|---|
| 174 |
|
|---|
| 175 | <xsl:call-template name="qanda.heading">
|
|---|
| 176 | <xsl:with-param name="level" select="$sectlvl + 1 + count(ancestor::qandadiv)"/>
|
|---|
| 177 | <xsl:with-param name="marker" select="0"/>
|
|---|
| 178 | <xsl:with-param name="title">
|
|---|
| 179 | <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
|
|---|
| 180 | <xsl:if test="$qandadiv.autolabel != 0">
|
|---|
| 181 | <xsl:apply-templates select="." mode="intralabel.punctuation"/>
|
|---|
| 182 | <xsl:text> </xsl:text>
|
|---|
| 183 | </xsl:if>
|
|---|
| 184 | <xsl:apply-templates/>
|
|---|
| 185 | </xsl:with-param>
|
|---|
| 186 | </xsl:call-template>
|
|---|
| 187 | </xsl:template>
|
|---|
| 188 |
|
|---|
| 189 | <xsl:template match="qandaentry">
|
|---|
| 190 | <!-- Omit revhistory from fo:list-block because it is a table -->
|
|---|
| 191 | <xsl:apply-templates select="question|answer"/>
|
|---|
| 192 | </xsl:template>
|
|---|
| 193 |
|
|---|
| 194 | <xsl:template match="question">
|
|---|
| 195 | <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
|
|---|
| 196 |
|
|---|
| 197 | <xsl:variable name="entry.id">
|
|---|
| 198 | <xsl:call-template name="object.id">
|
|---|
| 199 | <xsl:with-param name="object" select="parent::*"/>
|
|---|
| 200 | </xsl:call-template>
|
|---|
| 201 | </xsl:variable>
|
|---|
| 202 |
|
|---|
| 203 | <xsl:variable name="deflabel">
|
|---|
| 204 | <xsl:choose>
|
|---|
| 205 | <xsl:when test="ancestor-or-self::*[@defaultlabel]">
|
|---|
| 206 | <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
|
|---|
| 207 | /@defaultlabel"/>
|
|---|
| 208 | </xsl:when>
|
|---|
| 209 | <xsl:otherwise>
|
|---|
| 210 | <xsl:value-of select="$qanda.defaultlabel"/>
|
|---|
| 211 | </xsl:otherwise>
|
|---|
| 212 | </xsl:choose>
|
|---|
| 213 | </xsl:variable>
|
|---|
| 214 |
|
|---|
| 215 | <fo:list-item id="{$entry.id}" xsl:use-attribute-sets="list.item.spacing">
|
|---|
| 216 | <fo:list-item-label id="{$id}" end-indent="label-end()">
|
|---|
| 217 | <xsl:choose>
|
|---|
| 218 | <xsl:when test="$deflabel = 'none'">
|
|---|
| 219 | <fo:block/>
|
|---|
| 220 | </xsl:when>
|
|---|
| 221 | <xsl:otherwise>
|
|---|
| 222 | <fo:block>
|
|---|
| 223 | <xsl:apply-templates select="." mode="label.markup"/>
|
|---|
| 224 | <xsl:if test="$deflabel = 'number' and not(label)">
|
|---|
| 225 | <xsl:apply-templates select="." mode="intralabel.punctuation"/>
|
|---|
| 226 | </xsl:if>
|
|---|
| 227 | </fo:block>
|
|---|
| 228 | </xsl:otherwise>
|
|---|
| 229 | </xsl:choose>
|
|---|
| 230 | </fo:list-item-label>
|
|---|
| 231 | <fo:list-item-body start-indent="body-start()">
|
|---|
| 232 | <xsl:choose>
|
|---|
| 233 | <xsl:when test="$deflabel = 'none'">
|
|---|
| 234 | <fo:block font-weight="bold">
|
|---|
| 235 | <xsl:apply-templates select="*[local-name(.)!='label']"/>
|
|---|
| 236 | </fo:block>
|
|---|
| 237 | </xsl:when>
|
|---|
| 238 | <xsl:otherwise>
|
|---|
| 239 | <xsl:apply-templates select="*[local-name(.)!='label']"/>
|
|---|
| 240 | </xsl:otherwise>
|
|---|
| 241 | </xsl:choose>
|
|---|
| 242 | <!-- Uncomment this line to get revhistory output in the question -->
|
|---|
| 243 | <!-- <xsl:apply-templates select="preceding-sibling::revhistory"/> -->
|
|---|
| 244 | </fo:list-item-body>
|
|---|
| 245 | </fo:list-item>
|
|---|
| 246 | </xsl:template>
|
|---|
| 247 |
|
|---|
| 248 | <xsl:template match="answer">
|
|---|
| 249 | <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
|
|---|
| 250 | <xsl:variable name="entry.id">
|
|---|
| 251 | <xsl:call-template name="object.id">
|
|---|
| 252 | <xsl:with-param name="object" select="parent::*"/>
|
|---|
| 253 | </xsl:call-template>
|
|---|
| 254 | </xsl:variable>
|
|---|
| 255 |
|
|---|
| 256 | <xsl:variable name="deflabel">
|
|---|
| 257 | <xsl:choose>
|
|---|
| 258 | <xsl:when test="ancestor-or-self::*[@defaultlabel]">
|
|---|
| 259 | <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
|
|---|
| 260 | /@defaultlabel"/>
|
|---|
| 261 | </xsl:when>
|
|---|
| 262 | <xsl:otherwise>
|
|---|
| 263 | <xsl:value-of select="$qanda.defaultlabel"/>
|
|---|
| 264 | </xsl:otherwise>
|
|---|
| 265 | </xsl:choose>
|
|---|
| 266 | </xsl:variable>
|
|---|
| 267 |
|
|---|
| 268 | <fo:list-item xsl:use-attribute-sets="list.item.spacing">
|
|---|
| 269 | <fo:list-item-label id="{$id}" end-indent="label-end()">
|
|---|
| 270 | <xsl:choose>
|
|---|
| 271 | <xsl:when test="$deflabel = 'none'">
|
|---|
| 272 | <fo:block/>
|
|---|
| 273 | </xsl:when>
|
|---|
| 274 | <xsl:otherwise>
|
|---|
| 275 | <fo:block>
|
|---|
| 276 | <xsl:variable name="answer.label">
|
|---|
| 277 | <xsl:apply-templates select="." mode="label.markup"/>
|
|---|
| 278 | </xsl:variable>
|
|---|
| 279 | <xsl:copy-of select="$answer.label"/>
|
|---|
| 280 | </fo:block>
|
|---|
| 281 | </xsl:otherwise>
|
|---|
| 282 | </xsl:choose>
|
|---|
| 283 | </fo:list-item-label>
|
|---|
| 284 | <fo:list-item-body start-indent="body-start()">
|
|---|
| 285 | <xsl:apply-templates select="*[local-name(.)!='label']"/>
|
|---|
| 286 | </fo:list-item-body>
|
|---|
| 287 | </fo:list-item>
|
|---|
| 288 | </xsl:template>
|
|---|
| 289 |
|
|---|
| 290 | <xsl:template match="label">
|
|---|
| 291 | <xsl:apply-templates/>
|
|---|
| 292 | </xsl:template>
|
|---|
| 293 |
|
|---|
| 294 | <xsl:template name="qanda.heading">
|
|---|
| 295 | <xsl:param name="level" select="1"/>
|
|---|
| 296 | <xsl:param name="marker" select="0"/>
|
|---|
| 297 | <xsl:param name="title"/>
|
|---|
| 298 | <xsl:param name="titleabbrev"/>
|
|---|
| 299 |
|
|---|
| 300 | <fo:block xsl:use-attribute-sets="qanda.title.properties">
|
|---|
| 301 | <xsl:if test="$marker != 0">
|
|---|
| 302 | <fo:marker marker-class-name="section.head.marker">
|
|---|
| 303 | <xsl:choose>
|
|---|
| 304 | <xsl:when test="$titleabbrev = ''">
|
|---|
| 305 | <xsl:value-of select="$title"/>
|
|---|
| 306 | </xsl:when>
|
|---|
| 307 | <xsl:otherwise>
|
|---|
| 308 | <xsl:value-of select="$titleabbrev"/>
|
|---|
| 309 | </xsl:otherwise>
|
|---|
| 310 | </xsl:choose>
|
|---|
| 311 | </fo:marker>
|
|---|
| 312 | </xsl:if>
|
|---|
| 313 | <xsl:choose>
|
|---|
| 314 | <xsl:when test="$level=1">
|
|---|
| 315 | <fo:block xsl:use-attribute-sets="qanda.title.level1.properties">
|
|---|
| 316 | <xsl:copy-of select="$title"/>
|
|---|
| 317 | </fo:block>
|
|---|
| 318 | </xsl:when>
|
|---|
| 319 | <xsl:when test="$level=2">
|
|---|
| 320 | <fo:block xsl:use-attribute-sets="qanda.title.level2.properties">
|
|---|
| 321 | <xsl:copy-of select="$title"/>
|
|---|
| 322 | </fo:block>
|
|---|
| 323 | </xsl:when>
|
|---|
| 324 | <xsl:when test="$level=3">
|
|---|
| 325 | <fo:block xsl:use-attribute-sets="qanda.title.level3.properties">
|
|---|
| 326 | <xsl:copy-of select="$title"/>
|
|---|
| 327 | </fo:block>
|
|---|
| 328 | </xsl:when>
|
|---|
| 329 | <xsl:when test="$level=4">
|
|---|
| 330 | <fo:block xsl:use-attribute-sets="qanda.title.level4.properties">
|
|---|
| 331 | <xsl:copy-of select="$title"/>
|
|---|
| 332 | </fo:block>
|
|---|
| 333 | </xsl:when>
|
|---|
| 334 | <xsl:when test="$level=5">
|
|---|
| 335 | <fo:block xsl:use-attribute-sets="qanda.title.level5.properties">
|
|---|
| 336 | <xsl:copy-of select="$title"/>
|
|---|
| 337 | </fo:block>
|
|---|
| 338 | </xsl:when>
|
|---|
| 339 | <xsl:otherwise>
|
|---|
| 340 | <fo:block xsl:use-attribute-sets="qanda.title.level6.properties">
|
|---|
| 341 | <xsl:copy-of select="$title"/>
|
|---|
| 342 | </fo:block>
|
|---|
| 343 | </xsl:otherwise>
|
|---|
| 344 | </xsl:choose>
|
|---|
| 345 | </fo:block>
|
|---|
| 346 | </xsl:template>
|
|---|
| 347 |
|
|---|
| 348 | </xsl:stylesheet>
|
|---|