Next / Previous / Contents / Shipman's homepage

9.4. Question-and-answer sets

DocBook supports sets of questions and answers, such as Frequently Asked QUestions (FAQ) documents.

The top-level element for a set of questions and answers is qandaset. Here is a very simple set of two Q&A pairs:

Q: What is your favorite color?
Q: What is the air-speed velocity of an unladen swallow?

Q:

What is your favorite color?

A:

Blue.

Q:

What is the air-speed velocity of an unladen swallow?

A:

What do you mean? An African or European swallow?

Here's how that list is encoded:

      <qandaset defaultlabel='qanda'>
        <title>At the Bridge of Death</title>
        <qandaentry>
          <question>
            <para>
              What is your favorite color?
            </para>
          </question>
          <answer>
            <para>
              Blue.
            </para>
          </answer>
        </qandaentry>
        <qandaentry>
          <question>
            <para>
              What is the air-speed velocity of an unladen swallow?
            </para>
          </question>
          <answer>
            <para>
              What do you mean?  An African or European swallow?
            </para>
          </answer>
        </qandaentry>
      </qandaset>

If you want to structure your Q&A set into sections, you can use a qandadiv element inside your qandaset element, with one or more qandaentry elements inside that.

To give the section a title, use a title element after the qandadiv element.

Here's a partial example:

    <qandaset defaultlabel='qanda'>
      <title>Frequently axed questors</title>
      <qandadiv>
        <title>Trolls I have put down</title>
        <qandaentry>
          ...
        </qandaentry>
        ...
      </qandadiv>
      <qandadiv>
        <title>Castle Anthrax</title>
        <qandaentry>
          ...
        </qandaentry>
        ...
      </qandadiv>
    </qandaset>

You can even use qandadiv elements inside other qandadiv elements to divide your list into sublists, sub-sublists, and so on.