qandaset.xsl coverage = 1/127 ( 0.79%)

  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
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

<!--############################################################################
    XSLT Stylesheet DocBook -> LaTeX 
    ############################################################################ -->

<!-- qandaset parameters -->
<xsl:param name="qanda.defaultlabel">number</xsl:param>


<xsl:template match="qandaset">
  <!-- is it displayed as a section? -->
  <xsl:variable name="title"
                select="(title|blockinfo/title|info/title)[1]"/>

  <xsl:if test="$title">
    <xsl:call-template name="makeheading">
      <xsl:with-param name="level">
        <xsl:call-template name="get.sect.level"/>
      </xsl:with-param>
      <xsl:with-param name="num" select="'0'"/>
      <xsl:with-param name="title" select="$title"/>
    </xsl:call-template>
  </xsl:if>

  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="qandaset/title"/>
<xsl:template match="qandaset/blockinfo"/>


<!-- ############
     # qandadiv #
     ############ -->

<xsl:template match="qandadiv/title"/>

<xsl:template match="qandadiv">
  <!-- display the title according the section depth -->
  <xsl:variable name="l">
    <xsl:value-of select="count(ancestor::qandadiv)"/>
  </xsl:variable>
  <xsl:variable name="lset">
    <xsl:call-template name="get.sect.level">
      <xsl:with-param name="n" select="ancestor::qandaset"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:if test="blockinfo/title|info/title|title">
    <xsl:call-template name="makeheading">
      <xsl:with-param name="level">
        <xsl:choose>
        <xsl:when test="ancestor::qandaset[title|blockinfo/title|info/title]">
          <xsl:value-of select="$l+$lset+1"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$l+$lset"/>
        </xsl:otherwise>
        </xsl:choose>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:if>

  <xsl:apply-templates/>
</xsl:template>


<!-- ##############
     # qandaentry #
     ############## -->

<!-- should be really processed -->
<xsl:template match="label"/>

<xsl:template match="qandaentry">
  <xsl:variable name="defaultlabel">
    <xsl:choose>
    <xsl:when test="ancestor::qandaset[@defaultlabel]">
      <xsl:value-of select="ancestor::qandaset/@defaultlabel"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$qanda.defaultlabel"/>
    </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <!-- if default label is a number, display the quandaentries
       like an enumerate list
    -->
  <xsl:if test="not(preceding-sibling::qandaentry) and
                $defaultlabel='number'">
    <xsl:text>&#10;\begin{enumerate}&#10;</xsl:text>
  </xsl:if>

  <xsl:apply-templates select="question" mode="wp">
    <xsl:with-param name="defaultlabel" select="$defaultlabel"/>
  </xsl:apply-templates>
  <xsl:apply-templates select="answer" mode="wp">
    <xsl:with-param name="defaultlabel" select="$defaultlabel"/>
  </xsl:apply-templates>

  <xsl:if test="not(following-sibling::qandaentry) and
                $defaultlabel='number'">
    <xsl:text>&#10;\end{enumerate}</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="question" mode="wp">
  <xsl:param name="defaultlabel"/>

  <xsl:choose>
  <xsl:when test="$defaultlabel='number'">
    <xsl:text>\item</xsl:text>
    <xsl:if test="label">
      <!-- label has priority on defaultlabel -->
      <xsl:text>[\textbf{</xsl:text>
      <xsl:value-of select="label"/>
      <xsl:text>}]</xsl:text>
    </xsl:if>
    <xsl:text>{}</xsl:text>
  </xsl:when>
  <xsl:when test="label">
    <xsl:text>\textbf{</xsl:text>
    <xsl:value-of select="label"/>
    <xsl:text>}~</xsl:text>
  </xsl:when>
  <xsl:when test="$defaultlabel='qanda'">
    <xsl:text>\textbf{</xsl:text>
    <xsl:call-template name="gentext">
      <xsl:with-param name="key" select="'question'"/>
    </xsl:call-template>
    <xsl:text>}~</xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text>&#10;</xsl:text>
  </xsl:otherwise>
  </xsl:choose>

  <!-- don't use textit since we can have several paragraphs -->
  <xsl:text>{\it </xsl:text>
  <xsl:apply-templates/>
  <xsl:text>}&#10;</xsl:text>
</xsl:template>

<xsl:template match="answer" mode="wp">
  <xsl:param name="defaultlabel"/>

  <xsl:choose>
  <xsl:when test="$defaultlabel='number'">
    <!-- answers are other paragraphs of the enumerated entry -->
    <xsl:text>&#10;</xsl:text>
  </xsl:when>
  <xsl:when test="label">
    <xsl:text>&#10;\noindent\textbf{</xsl:text>
    <xsl:value-of select="label"/>
    <xsl:text>}~</xsl:text>
  </xsl:when>
  <xsl:when test="$defaultlabel='qanda'">
    <xsl:text>&#10;\noindent\textbf{</xsl:text>
    <xsl:call-template name="gentext">
      <xsl:with-param name="key" select="'answer'"/>
    </xsl:call-template>
    <xsl:text>}~</xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text>&#10;</xsl:text>
  </xsl:otherwise>
  </xsl:choose>

  <xsl:apply-templates/>
  <xsl:text>&#10;&#10;</xsl:text>
</xsl:template>


</xsl:stylesheet>