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$
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<xsl:variable name="qanda.defaultlabel">number</xsl:variable>
17<xsl:variable name="generate.qandaset.toc" select="true()"/>
18<xsl:variable name="generate.qandadiv.toc" select="false()"/>
19
20<!-- ==================================================================== -->
21
22<xsl:template match="qandaset">
23  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
24
25  <fo:block id="{$id}">
26    <xsl:if test="title">
27      <xsl:apply-templates select="title"/>
28    </xsl:if>
29
30    <xsl:apply-templates select="*[name(.) != 'title'
31                                 and name(.) != 'qandadiv'
32                                 and name(.) != 'qandaentry']"/>
33    <xsl:apply-templates select="qandadiv"/>
34
35    <xsl:if test="qandaentry">
36      <fo:list-block xsl:use-attribute-sets="list.block.spacing"
37                     provisional-distance-between-starts="2.5em"
38                     provisional-label-separation="0.2em">
39        <xsl:apply-templates select="qandaentry"/>
40      </fo:list-block>
41    </xsl:if>
42  </fo:block>
43</xsl:template>
44
45<xsl:template match="qandaset/title">
46  <xsl:variable name="enclsect" select="(ancestor::section
47                                        | ancestor::simplesect
48                                        | ancestor::sect5
49                                        | ancestor::sect4
50                                        | ancestor::sect3
51                                        | ancestor::sect2
52                                        | ancestor::sect1
53                                        | ancestor::refsect3
54                                        | ancestor::refsect2
55                                        | ancestor::refsect1)[last()]"/>
56  <xsl:variable name="sectlvl">
57    <xsl:call-template name="section.level">
58      <xsl:with-param name="node" select="$enclsect"/>
59    </xsl:call-template>
60  </xsl:variable>
61
62  <xsl:call-template name="section.heading">
63    <xsl:with-param name="level" select="$sectlvl"/>
64    <xsl:with-param name="title" select="."/>
65  </xsl:call-template>
66</xsl:template>
67
68<xsl:template match="qandadiv">
69  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
70
71  <fo:block id="{$id}">
72    <xsl:apply-templates select="title"/>
73    <xsl:apply-templates select="*[name(.) != 'title'
74                                 and name(.) != 'qandadiv'
75                                 and name(.) != 'qandaentry']"/>
76    <fo:block start-indent="{count(ancestor::qandadiv)*2}pc">
77      <xsl:apply-templates select="qandadiv"/>
78
79      <xsl:if test="qandaentry">
80        <fo:list-block xsl:use-attribute-sets="list.block.spacing"
81                       provisional-distance-between-starts="2.5em"
82                       provisional-label-separation="0.2em">
83          <xsl:apply-templates select="qandaentry"/>
84        </fo:list-block>
85      </xsl:if>
86    </fo:block>
87  </fo:block>
88</xsl:template>
89
90<xsl:template match="qandadiv/title">
91  <xsl:variable name="enclsect" select="(ancestor::section
92                                        | ancestor::simplesect
93                                        | ancestor::sect5
94                                        | ancestor::sect4
95                                        | ancestor::sect3
96                                        | ancestor::sect2
97                                        | ancestor::sect1
98                                        | ancestor::refsect3
99                                        | ancestor::refsect2
100                                        | ancestor::refsect1)[last()]"/>
101  <xsl:variable name="sectlvl">
102    <xsl:call-template name="section.level">
103      <xsl:with-param name="node" select="$enclsect"/>
104    </xsl:call-template>
105  </xsl:variable>
106
107  <xsl:call-template name="section.heading">
108    <xsl:with-param name="level" select="$sectlvl + count(ancestor::qandadiv)"/>
109    <xsl:with-param name="title" select="."/>
110  </xsl:call-template>
111</xsl:template>
112
113<xsl:template match="qandaentry">
114  <xsl:apply-templates/>
115<!--
116  <fo:block>
117    <xsl:if test="@id">
118      <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
119    </xsl:if>
120    <xsl:apply-templates/>
121  </fo:block>
122-->
123</xsl:template>
124
125<xsl:template match="question|answer">
126  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
127  <xsl:variable name="entry.id">
128    <xsl:call-template name="object.id">
129      <xsl:with-param name="object" select="parent::*"/>
130    </xsl:call-template>
131  </xsl:variable>
132
133  <fo:list-item id="{$entry.id}" xsl:use-attribute-sets="list.item.spacing">
134    <fo:list-item-label id="{$id}" end-indent="label-end()">
135      <fo:block>
136        <xsl:call-template name="question.answer.label"/>
137      </fo:block>
138    </fo:list-item-label>
139    <fo:list-item-body start-indent="body-start()">
140      <xsl:apply-templates/>
141    </fo:list-item-body>
142  </fo:list-item>
143</xsl:template>
144
145</xsl:stylesheet>
146