]> granicus.if.org Git - docbook-dsssl/commitdiff
Add support for qandaset as root element to generate a page sequence.
authorBob Stayton <bobs@sagehill.net>
Sun, 7 May 2006 07:19:51 +0000 (07:19 +0000)
committerBob Stayton <bobs@sagehill.net>
Sun, 7 May 2006 07:19:51 +0000 (07:19 +0000)
xsl/fo/qandaset.xsl

index 21a6236791d2aec2da8cf72cca4ad1699c8f5cf4..1c67826d51483b8071c57bc95fb878d24edc7985 100644 (file)
@@ -16,7 +16,9 @@
 <!-- ==================================================================== -->
 
 <xsl:template match="qandaset">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
 
   <xsl:variable name="label-width">
     <xsl:call-template name="dbfo-attribute">
       <xsl:otherwise>2.5em</xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
+  
+  <xsl:variable name="content">
+    <fo:block id="{$id}">
+      <xsl:choose>
+        <xsl:when test="parent::*">
+          <xsl:if test="blockinfo/title|info/title|title">
+            <xsl:apply-templates select="(blockinfo/title|
+                                          info/title|title)[1]"/>
+          </xsl:if>
+        </xsl:when>
+        <!-- If it is the root element -->
+        <xsl:otherwise>
+          <xsl:call-template name="qandaset.titlepage"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  
+      <xsl:apply-templates select="*[name(.) != 'title'
+                                   and name(.) != 'titleabbrev'
+                                   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-label-separation="0.2em">
+          <xsl:attribute name="provisional-distance-between-starts">
+            <xsl:choose>
+              <xsl:when test="$label-length != ''">
+                <xsl:value-of select="$label-length"/>
+              </xsl:when>
+              <xsl:otherwise>2.5em</xsl:otherwise>
+            </xsl:choose>
+          </xsl:attribute>
+          <xsl:apply-templates select="qandaentry"/>
+        </fo:list-block>
+      </xsl:if>
+    </fo:block>
+  </xsl:variable>
 
-  <fo:block id="{$id}">
-    <xsl:if test="blockinfo/title|info/title|title">
-      <xsl:apply-templates select="(blockinfo/title|info/title|title)[1]"/>
-    </xsl:if>
-
-    <xsl:apply-templates select="*[name(.) != 'title'
-                                 and name(.) != 'titleabbrev'
-                                 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-label-separation="0.2em">
-       <xsl:attribute name="provisional-distance-between-starts">
-         <xsl:choose>
-           <xsl:when test="$label-length != ''">
-             <xsl:value-of select="$label-length"/>
-           </xsl:when>
-           <xsl:otherwise>2.5em</xsl:otherwise>
-         </xsl:choose>
-       </xsl:attribute>
-        <xsl:apply-templates select="qandaentry"/>
-      </fo:list-block>
-    </xsl:if>
-  </fo:block>
+  <xsl:choose>
+    <xsl:when test="parent::*">
+      <xsl:copy-of select="$content"/>
+    </xsl:when>
+    <!-- Otherwise create a page sequence -->
+    <xsl:otherwise>
+      <xsl:apply-templates select="." mode="page.sequence">
+        <xsl:with-param name="content" select="$content"/>
+        <xsl:with-param name="master-reference" select="'body'"/>
+      </xsl:apply-templates>
+    </xsl:otherwise>
+  </xsl:choose>
+  
 </xsl:template>
 
 <xsl:template match="qandaset/blockinfo/title|qandset/info/title|qandaset/title">