<xsl:value-of select="count($anc.divs) + number($section.level)"/>
</xsl:template>
+<xsl:template name="question.answer.label">
+ <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>
+
+ <xsl:variable name="label" select="@label"/>
+
+<!--
+ (hnr (hierarchical-number-recursive (normalize "qandadiv")
+ node))
+
+ (parsect (ancestor-member node (section-element-list)))
+
+ (defnum (if (and %qanda-inherit-numeration%
+ %section-autolabel%)
+ (if (node-list-empty? parsect)
+ (section-autolabel-prefix node)
+ (section-autolabel parsect))
+ ""))
+
+ (hnumber (let loop ((numlist hnr) (number defnum)
+ (sep (if (equal? defnum "") "" ".")))
+ (if (null? numlist)
+ number
+ (loop (cdr numlist)
+ (string-append number
+ sep
+ (number->string (car numlist)))
+ "."))))
+ (cnumber (child-number (parent node)))
+ (number (string-append hnumber
+ (if (equal? hnumber "")
+ ""
+ ".")
+ (number->string cnumber))))
+-->
+
+ <xsl:choose>
+ <xsl:when test="$deflabel = 'qanda'">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key">
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'question'">Question</xsl:when>
+ <xsl:when test="local-name(.) = 'question'">Answer</xsl:when>
+ <xsl:when test="local-name(.) = 'qandadiv'">QandADiv</xsl:when>
+ <xsl:otherwise>QandASet</xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$deflabel = 'label'">
+ <xsl:value-of select="$label"/>
+ </xsl:when>
+ <xsl:when test="$deflabel = 'number'
+ and local-name(.) = 'question'">
+ <xsl:apply-templates select="ancestor::qandaset[1]"
+ mode="number"/>
+ <xsl:choose>
+ <xsl:when test="ancestor::qandadiv">
+ <xsl:apply-templates select="ancestor::qandadiv[1]"
+ mode="number"/>
+ <xsl:apply-templates select="ancestor::qandaentry"
+ mode="number"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="ancestor::qandaentry"
+ mode="number"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- nothing -->
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="qandaset" mode="number">
+ <!-- FIXME: -->
+</xsl:template>
+
+<xsl:template match="qandadiv" mode="number">
+ <xsl:number level="multiple" from="qandaset" format="1."/>
+</xsl:template>
+
+<xsl:template match="qandaentry" mode="number">
+ <xsl:choose>
+ <xsl:when test="ancestor::qandadiv">
+ <xsl:number level="single" from="qandadiv" format="1."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:number level="single" from="qandaset" format="1."/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<!-- ====================================================================== -->
<xsl:template name="object.id">
<?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'>
<!-- ********************************************************************
<!-- ==================================================================== -->
-<!-- FIXME: WRITE THIS! -->
+<xsl:template match="qandaset">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+ <fo:block id="{$id}">
+ <xsl:if test="title">
+ <xsl:apply-templates select="title"/>
+ </xsl:if>
+
+ <xsl:apply-templates select="*[name(.) != 'title'
+ 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-distance-between-starts="2.5em"
+ provisional-label-separation="0.2em">
+ <xsl:apply-templates select="qandaentry"/>
+ </fo:list-block>
+ </xsl:if>
+ </fo:block>
+</xsl:template>
+
+<xsl:template match="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="section.heading">
+ <xsl:with-param name="level" select="$sectlvl"/>
+ <xsl:with-param name="title" select="."/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="qandadiv">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+ <fo:block id="{$id}">
+ <xsl:apply-templates select="title"/>
+ <xsl:apply-templates select="*[name(.) != 'title'
+ 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-distance-between-starts="2.5em"
+ provisional-label-separation="0.2em">
+ <xsl:apply-templates select="qandaentry"/>
+ </fo:list-block>
+ </xsl:if>
+ </fo:block>
+ </fo:block>
+</xsl:template>
+
+<xsl:template match="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="section.heading">
+ <xsl:with-param name="level" select="$sectlvl + count(ancestor::qandadiv)"/>
+ <xsl:with-param name="title" select="."/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="qandaentry">
+ <xsl:apply-templates/>
+<!--
+ <fo:block>
+ <xsl:if test="@id">
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </fo:block>
+-->
+</xsl:template>
+
+<xsl:template match="question|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>
+
+ <fo:list-item id="{$entry.id}" xsl:use-attribute-sets="list.item.spacing">
+ <fo:list-item-label id="{$id}" end-indent="label-end()">
+ <fo:block>
+ <xsl:call-template name="question.answer.label"/>
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <xsl:apply-templates/>
+ </fo:list-item-body>
+ </fo:list-item>
+</xsl:template>
</xsl:stylesheet>