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