1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4                exclude-result-prefixes="doc"
5                version='1.0'>
6
7<!-- ********************************************************************
8     $Id$
9     ********************************************************************
10
11     This file is part of the XSL DocBook Stylesheet distribution.
12     See /README or http://nwalsh.com/docbook/xsl/ for copyright
13     and other information.
14
15     ******************************************************************** -->
16
17<!-- ==================================================================== -->
18
19<xsl:template match="qandaset">
20  <xsl:variable name="title" select="title"/>
21  <xsl:variable name="rest" select="*[name(.)!='title']"/>
22
23  <div class="{name(.)}">
24    <xsl:apply-templates select="$title"/>
25    <xsl:if test="$generate.qandaset.toc != '0'">
26      <xsl:call-template name="process.qanda.toc"/>
27    </xsl:if>
28    <xsl:apply-templates select="$rest"/>
29  </div>
30</xsl:template>
31
32<xsl:template match="qandaset/title">
33  <xsl:variable name="qalevel">
34    <xsl:call-template name="qanda.section.level"/>
35  </xsl:variable>
36  <xsl:element name="h{string(number($qalevel)+1)}">
37    <xsl:attribute name="class">
38      <xsl:value-of select="name(.)"/>
39    </xsl:attribute>
40    <xsl:apply-templates/>
41  </xsl:element>
42</xsl:template>
43
44<xsl:template match="qandadiv">
45  <xsl:variable name="title" select="title"/>
46  <xsl:variable name="rest" select="*[name(.)!='title']"/>
47
48  <div class="{name(.)}">
49    <xsl:apply-templates select="$title"/>
50    <xsl:if test="$generate.qandadiv.toc != '0'">
51      <xsl:call-template name="process.qanda.toc"/>
52    </xsl:if>
53    <xsl:apply-templates select="$rest"/>
54  </div>
55</xsl:template>
56
57<xsl:template match="qandadiv/title">
58  <xsl:variable name="qalevel">
59    <xsl:call-template name="qandadiv.section.level"/>
60  </xsl:variable>
61  <xsl:variable name="id">
62    <xsl:call-template name="object.id">
63      <xsl:with-param name="object" select="parent::*"/>
64    </xsl:call-template>
65  </xsl:variable>
66
67  <xsl:element name="h{string(number($qalevel)+1)}">
68    <xsl:attribute name="class">
69      <xsl:value-of select="name(.)"/>
70    </xsl:attribute>
71    <a name="{$id}"/>
72    <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
73    <xsl:text> </xsl:text>
74    <xsl:apply-templates/>
75  </xsl:element>
76</xsl:template>
77
78<xsl:template match="qandaentry">
79  <div class="{name(.)}">
80    <xsl:apply-templates/>
81  </div>
82</xsl:template>
83
84<xsl:template match="question">
85  <xsl:variable name="firstch" select="(*[name(.)!='label'
86                                          and name(.)!='indexterm'])[1]"/>
87  <xsl:variable name="restch" select="(*[name(.)!='label'
88                                         and name(.)!='indexterm'])[position()!=1]
89                                      |indexterm"/>
90  <xsl:variable name="id">
91    <xsl:call-template name="object.id"/>
92  </xsl:variable>
93
94  <div class="{name(.)}">
95    <p>
96      <xsl:if test="../@id">
97        <a>
98          <xsl:attribute name="name">
99            <xsl:call-template name="object.id">
100              <xsl:with-param name="object" select="parent::*"/>
101            </xsl:call-template>
102          </xsl:attribute>
103        </a>
104      </xsl:if>
105      <a name="{$id}"/>
106      <b>
107        <xsl:apply-templates select="." mode="label.markup"/>
108        <xsl:text> </xsl:text>
109      </b>
110      <xsl:apply-templates select="$firstch" mode="no.wrapper.mode"/>
111    </p>
112    <xsl:apply-templates select="$restch"/>
113  </div>
114</xsl:template>
115
116<xsl:template match="answer">
117  <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
118  <xsl:variable name="restch" select="(*[name(.)!='label'])[position()!=1]"/>
119  <xsl:variable name="id">
120    <xsl:call-template name="object.id"/>
121  </xsl:variable>
122
123  <div class="{name(.)}">
124    <p>
125      <a name="{$id}"/>
126      <b>
127        <xsl:apply-templates select="." mode="label.markup"/>
128        <xsl:text> </xsl:text>
129      </b>
130      <xsl:apply-templates select="$firstch" mode="no.wrapper.mode"/>
131    </p>
132    <xsl:apply-templates select="$restch"/>
133  </div>
134</xsl:template>
135
136<xsl:template match="label">
137  <xsl:apply-templates/>
138</xsl:template>
139
140<!-- ==================================================================== -->
141
142<xsl:template name="process.qanda.toc">
143  <dl>
144    <xsl:apply-templates select="qandadiv" mode="qandatoc.mode"/>
145    <xsl:apply-templates select="qandaentry" mode="qandatoc.mode"/>
146  </dl>
147</xsl:template>
148
149<xsl:template match="qandadiv" mode="qandatoc.mode">
150  <dt><xsl:apply-templates select="title" mode="qandatoc.mode"/></dt>
151  <dd><xsl:call-template name="process.qanda.toc"/></dd>
152</xsl:template>
153
154<xsl:template match="qandadiv/title" mode="qandatoc.mode">
155  <xsl:variable name="qalevel">
156    <xsl:call-template name="qandadiv.section.level"/>
157  </xsl:variable>
158  <xsl:variable name="id">
159    <xsl:call-template name="object.id">
160      <xsl:with-param name="object" select="parent::*"/>
161    </xsl:call-template>
162  </xsl:variable>
163
164  <xsl:apply-templates select="parent::qandadiv" mode="label.markup"/>
165  <xsl:text> </xsl:text>
166  <a>
167    <xsl:attribute name="href">
168      <xsl:call-template name="href.target">
169        <xsl:with-param name="object" select="parent::*"/>
170      </xsl:call-template>
171    </xsl:attribute>
172    <xsl:apply-templates/>
173  </a>
174</xsl:template>
175
176<xsl:template match="qandaentry" mode="qandatoc.mode">
177  <xsl:apply-templates mode="qandatoc.mode"/>
178</xsl:template>
179
180<xsl:template match="question" mode="qandatoc.mode">
181  <xsl:variable name="firstch" select="(*[name(.)!='label'])[1]"/>
182
183  <dt>
184    <xsl:apply-templates select="." mode="label.markup"/>
185    <xsl:text> </xsl:text>
186    <a>
187      <xsl:attribute name="href">
188        <xsl:call-template name="href.target"/>
189      </xsl:attribute>
190      <xsl:value-of select="$firstch"/>
191    </a>
192  </dt>
193</xsl:template>
194
195<xsl:template match="answer|revhistory" mode="qandatoc.mode">
196  <!-- nop -->
197</xsl:template>
198
199<!-- ==================================================================== -->
200
201<xsl:template match="*" mode="no.wrapper.mode">
202  <xsl:apply-templates/>
203</xsl:template>
204
205<!-- ==================================================================== -->
206
207</xsl:stylesheet>
208