]> granicus.if.org Git - docbook-dsssl/commitdiff
Make glossary parameters properly documented parameters; support glossary.as.blocks
authorNorman Walsh <ndw@nwalsh.com>
Thu, 27 Jun 2002 14:05:55 +0000 (14:05 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 27 Jun 2002 14:05:55 +0000 (14:05 +0000)
xsl/fo/glossary.xsl
xsl/fo/param.ent
xsl/fo/param.xweb
xsl/params/glossary.as.blocks.xml [new file with mode: 0644]
xsl/params/glosslist.as.blocks.xml [new file with mode: 0644]
xsl/params/glossterm.separation.xml [new file with mode: 0644]
xsl/params/glossterm.width.xml [new file with mode: 0644]

index 8697efaa355bf7e51dc64b9c95758b7b6153c2c7..f1629e56cf3e430399bc506d6f42c6f12c06d4f6 100644 (file)
 
 <!-- ==================================================================== -->
 
-<xsl:variable name="glossterm-width">2in</xsl:variable>
-<xsl:variable name="glossterm-sep">0.25in</xsl:variable>
-
-<!-- ==================================================================== -->
-
 <xsl:template match="glossary">
-  <xsl:variable name="divs" select="glossdiv"/>
-  <xsl:variable name="entries" select="glossentry"/>
-  <xsl:variable name="preamble"
-                select="*[not(self::title
-                            or self::subtitle
-                            or self::glossdiv
-                            or self::glossentry)]"/>
-
   <xsl:variable name="id">
     <xsl:call-template name="object.id"/>
   </xsl:variable>
-
   <fo:block id="{$id}">
-    <xsl:call-template name="component.separator"/>
+    <xsl:call-template name="make-glossary"/>
+  </fo:block>
+</xsl:template>
 
-    <xsl:call-template name="glossary.titlepage"/>
+<xsl:template name="make-glossary">
+  <xsl:param name="divs" select="glossdiv"/>
+  <xsl:param name="entries" select="glossentry"/>
+  <xsl:param name="preamble" select="*[not(self::title
+                                           or self::subtitle
+                                           or self::glossdiv
+                                           or self::glossentry)]"/>
+
+  <xsl:variable name="presentation">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'glossary-presentation'"/>
+    </xsl:call-template>
+  </xsl:variable>
 
-    <xsl:if test="$preamble">
-      <xsl:apply-templates select="$preamble"/>
-    </xsl:if>
+  <xsl:variable name="term-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'glossterm-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
 
-    <xsl:if test="$divs">
-      <xsl:apply-templates select="$divs"/>
-    </xsl:if>
+  <xsl:variable name="width">
+    <xsl:choose>
+      <xsl:when test="$term-width = ''">
+        <xsl:value-of select="$glossterm.width"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$term-width"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
 
-    <xsl:if test="$entries">
-      <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                     provisional-label-separation="{$glossterm-sep}"
-                     xsl:use-attribute-sets="normal.para.spacing">
-        <xsl:apply-templates select="$entries"/>
-      </fo:list-block>
-    </xsl:if>
-  </fo:block>
-</xsl:template>
+  <xsl:call-template name="glossary.titlepage"/>
 
-<xsl:template match="book/glossary">
-  <xsl:variable name="divs" select="glossdiv"/>
-  <xsl:variable name="entries" select="glossentry"/>
-  <xsl:variable name="preamble"
-                select="*[not(self::title
-                            or self::subtitle
-                            or self::glossdiv
-                            or self::glossentry)]"/>
+  <xsl:if test="$preamble">
+    <xsl:apply-templates select="$preamble"/>
+  </xsl:if>
+
+  <xsl:choose>
+    <xsl:when test="$presentation = 'list'">
+      <xsl:apply-templates select="$divs" mode="glossary.as.list">
+        <xsl:with-param name="width" select="$width"/>
+      </xsl:apply-templates>
+      <xsl:if test="$entries">
+        <fo:list-block provisional-distance-between-starts="{$width}"
+                       provisional-label-separation="{$glossterm.separation}"
+                       xsl:use-attribute-sets="normal.para.spacing">
+          <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
+        </fo:list-block>
+      </xsl:if>
+    </xsl:when>
+    <xsl:when test="$presentation = 'blocks'">
+      <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
+      <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
+    </xsl:when>
+    <xsl:when test="$glossary.as.blocks != 0">
+      <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
+      <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates select="$divs" mode="glossary.as.list">
+        <xsl:with-param name="width" select="$width"/>
+      </xsl:apply-templates>
+      <xsl:if test="$entries">
+        <fo:list-block provisional-distance-between-starts="{$width}"
+                       provisional-label-separation="{$glossterm.separation}"
+                       xsl:use-attribute-sets="normal.para.spacing">
+          <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
+        </fo:list-block>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
 
+<xsl:template match="book/glossary|/glossary" priority="2">
   <xsl:variable name="id">
     <xsl:call-template name="object.id"/>
   </xsl:variable>
     </xsl:apply-templates>
 
     <fo:flow flow-name="xsl-region-body">
-      <xsl:call-template name="glossary.titlepage"/>
-
-      <xsl:if test="$preamble">
-        <xsl:apply-templates select="$preamble"/>
-      </xsl:if>
-
-      <xsl:if test="$divs">
-        <xsl:apply-templates select="$divs"/>
-      </xsl:if>
-
-      <xsl:if test="$entries">
-        <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                       provisional-label-separation="{$glossterm-sep}"
-                       xsl:use-attribute-sets="normal.para.spacing">
-          <xsl:apply-templates select="$entries"/>
-        </fo:list-block>
-      </xsl:if>
+      <xsl:call-template name="make-glossary"/>
     </fo:flow>
   </fo:page-sequence>
 </xsl:template>
 <xsl:template match="glossary/titleabbrev"></xsl:template>
 
 <xsl:template match="glossary/title" mode="component.title.mode">
-  <fo:block font-size="18pt"
-            font-weight="bold"
-            keep-with-next.within-column="always"
-            hyphenate="false">
+  <fo:block xsl:use-attribute-sets="component.title.properties">
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>
 
 <xsl:template match="glossary/subtitle" mode="component.title.mode">
-  <fo:block font-size="16pt"
-            font-weight="bold"
-            font-style="italic"
-            keep-with-next.within-column="always"
-            hyphenate="false">
+  <fo:block font-size="18pt" font-weight="bold" font-style="italic">
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>
 <!-- ==================================================================== -->
 
 <xsl:template match="glosslist">
-  <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                 provisional-label-separation="{$glossterm-sep}"
-                 xsl:use-attribute-sets="normal.para.spacing">
-      <xsl:apply-templates/>
-    </fo:list-block>
+  <xsl:variable name="presentation">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'glosslist-presentation'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="term-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'glossterm-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="width">
+    <xsl:choose>
+      <xsl:when test="$term-width = ''">
+        <xsl:value-of select="$glossterm.width"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$term-width"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$presentation = 'list'">
+      <fo:list-block provisional-distance-between-starts="{$width}"
+                     provisional-label-separation="{$glossterm.separation}"
+                     xsl:use-attribute-sets="normal.para.spacing">
+        <xsl:apply-templates mode="glossary.as.list"/>
+      </fo:list-block>
+    </xsl:when>
+    <xsl:when test="$presentation = 'blocks'">
+      <xsl:apply-templates mode="glossary.as.blocks"/>
+    </xsl:when>
+    <xsl:when test="$glosslist.as.blocks != 0">
+      <xsl:apply-templates mode="glossary.as.blocks"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:list-block provisional-distance-between-starts="{$width}"
+                     provisional-label-separation="{$glossterm.separation}"
+                     xsl:use-attribute-sets="normal.para.spacing">
+        <xsl:apply-templates mode="glossary.as.list"/>
+      </fo:list-block>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <!-- ==================================================================== -->
 
-<xsl:template match="glossdiv">
-  <xsl:variable name="entries" select="glossentry"/>
+<xsl:template match="glossdiv/title">
+  <fo:block font-size="16pt" font-weight="bold">
+    <xsl:apply-templates/>
+  </fo:block>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="glossentry" mode="xref">
+  <xsl:apply-templates select="./glossterm[1]" mode="xref"/>
+</xsl:template>
+
+<xsl:template match="glossterm" mode="xref">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id">
+      <xsl:with-param name="object" select="parent::glossentry"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <fo:basic-link internal-destination="{$id}"
+                 xsl:use-attribute-sets="xref.properties">
+    <xsl:apply-templates/>
+    <xsl:call-template name="insert.page.citation">
+      <xsl:with-param name="id" select="$id"/>
+    </xsl:call-template>
+  </fo:basic-link>
+</xsl:template>
+
+<!-- ==================================================================== -->
+<!-- Glossary collection -->
+
+<xsl:template match="glossary[@role='auto']" priority="2">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+  <xsl:if test="$glossary.collection = ''">
+    <xsl:message>
+      <xsl:text>Warning: processing automatic glossary </xsl:text>
+      <xsl:text>without a glossary.collection file.</xsl:text>
+    </xsl:message>
+  </xsl:if>
+
+  <fo:block id="{$id}">
+    <xsl:call-template name="make-auto-glossary"/>
+  </fo:block>
+</xsl:template>
+
+<xsl:template name="make-auto-glossary">
+  <xsl:param name="collection" select="document($glossary.collection, .)"/>
+  <xsl:param name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
+  <xsl:param name="preamble" select="*[not(self::title
+                                           or self::subtitle
+                                           or self::glossdiv
+                                           or self::glossentry)]"/>
+
+  <xsl:variable name="presentation">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'glossary-presentation'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="term-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'glossterm-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="width">
+    <xsl:choose>
+      <xsl:when test="$term-width = ''">
+        <xsl:value-of select="$glossterm.width"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$term-width"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:if test="$glossary.collection = ''">
+    <xsl:message>
+      <xsl:text>Warning: processing automatic glossary </xsl:text>
+      <xsl:text>without a glossary.collection file.</xsl:text>
+    </xsl:message>
+  </xsl:if>
+
+  <xsl:call-template name="glossary.titlepage"/>
+
+  <xsl:if test="$preamble">
+    <xsl:apply-templates select="$preamble"/>
+  </xsl:if>
+
+  <xsl:choose>
+    <xsl:when test="glossdiv and $collection//glossdiv">
+      <xsl:for-each select="$collection//glossdiv">
+        <!-- first see if there are any in this div -->
+        <xsl:variable name="exist.test">
+          <xsl:for-each select="glossentry">
+            <xsl:variable name="cterm" select="glossterm"/>
+            <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+              <xsl:value-of select="glossterm"/>
+            </xsl:if>
+          </xsl:for-each>
+        </xsl:variable>
+
+        <xsl:if test="$exist.test != ''">
+          <xsl:choose>
+            <xsl:when test="$presentation = 'list'">
+              <xsl:apply-templates select="." mode="auto-glossary-as-list">
+                <xsl:with-param name="width" select="$width"/>
+                <xsl:with-param name="terms" select="$terms"/>
+              </xsl:apply-templates>
+            </xsl:when>
+            <xsl:when test="$presentation = 'blocks'">
+              <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
+                <xsl:with-param name="terms" select="$terms"/>
+              </xsl:apply-templates>
+            </xsl:when>
+            <xsl:when test="$glossary.as.blocks != 0">
+              <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
+                <xsl:with-param name="terms" select="$terms"/>
+              </xsl:apply-templates>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:apply-templates select="." mode="auto-glossary-as-list">
+                <xsl:with-param name="width" select="$width"/>
+                <xsl:with-param name="terms" select="$terms"/>
+              </xsl:apply-templates>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:if>
+      </xsl:for-each>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="$presentation = 'list'">
+          <fo:list-block provisional-distance-between-starts="{$width}"
+                         provisional-label-separation="{$glossterm.separation}"
+                         xsl:use-attribute-sets="normal.para.spacing">
+            <xsl:for-each select="$collection//glossentry">
+              <xsl:variable name="cterm" select="glossterm"/>
+              <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+                <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
+              </xsl:if>
+            </xsl:for-each>
+          </fo:list-block>
+        </xsl:when>
+        <xsl:when test="$presentation = 'blocks'">
+          <xsl:for-each select="$collection//glossentry">
+            <xsl:variable name="cterm" select="glossterm"/>
+            <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+              <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
+            </xsl:if>
+          </xsl:for-each>
+        </xsl:when>
+        <xsl:when test="$glossary.as.blocks != 0">
+          <xsl:for-each select="$collection//glossentry">
+            <xsl:variable name="cterm" select="glossterm"/>
+            <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+              <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
+            </xsl:if>
+          </xsl:for-each>
+        </xsl:when>
+        <xsl:otherwise>
+          <fo:list-block provisional-distance-between-starts="{$width}"
+                         provisional-label-separation="{$glossterm.separation}"
+                         xsl:use-attribute-sets="normal.para.spacing">
+            <xsl:for-each select="$collection//glossentry">
+              <xsl:variable name="cterm" select="glossterm"/>
+              <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+                <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
+              </xsl:if>
+            </xsl:for-each>
+          </fo:list-block>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="book/glossary[@role='auto']|/glossary[@role='auto']" priority="2.5">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+  <xsl:variable name="master-reference">
+    <xsl:call-template name="select.pagemaster"/>
+  </xsl:variable>
+
+  <xsl:if test="$glossary.collection = ''">
+    <xsl:message>
+      <xsl:text>Warning: processing automatic glossary </xsl:text>
+      <xsl:text>without a glossary.collection file.</xsl:text>
+    </xsl:message>
+  </xsl:if>
+
+  <fo:page-sequence id="{$id}"
+                    hyphenate="{$hyphenate}"
+                    master-reference="{$master-reference}">
+    <xsl:attribute name="language">
+      <xsl:call-template name="l10n.language"/>
+    </xsl:attribute>
+    <xsl:if test="$double.sided != 0">
+      <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
+    </xsl:if>
+
+    <xsl:apply-templates select="." mode="running.head.mode">
+      <xsl:with-param name="master-reference" select="$master-reference"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates select="." mode="running.foot.mode">
+      <xsl:with-param name="master-reference" select="$master-reference"/>
+    </xsl:apply-templates>
+
+    <fo:flow flow-name="xsl-region-body">
+      <xsl:call-template name="make-auto-glossary"/>
+    </fo:flow>
+  </fo:page-sequence>
+</xsl:template>
+
+<xsl:template match="glossdiv" mode="auto-glossary-as-list">
+  <xsl:param name="width" select="$glossterm.width"/>
+  <xsl:param name="terms" select="."/>
+
   <xsl:variable name="preamble"
                 select="*[not(self::title
                             or self::subtitle
 
   <xsl:apply-templates select="title|subtitle"/>
   <xsl:apply-templates select="$preamble"/>
-  <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                 provisional-label-separation="{$glossterm-sep}"
+  <fo:list-block provisional-distance-between-starts="{$width}"
+                 provisional-label-separation="{$glossterm.separation}"
                  xsl:use-attribute-sets="normal.para.spacing">
-    <xsl:apply-templates select="$entries"/>
+    <xsl:for-each select="glossentry">
+      <xsl:variable name="cterm" select="glossterm"/>
+      <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+        <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
+      </xsl:if>
+    </xsl:for-each>
   </fo:list-block>
 </xsl:template>
 
-<xsl:template match="glossdiv/title">
-  <fo:block font-size="16pt" font-weight="bold">
-    <xsl:apply-templates/>
-  </fo:block>
+<xsl:template match="glossentry" mode="auto-glossary-as-list">
+  <xsl:apply-templates select="." mode="glossary.as.list"/>
+</xsl:template>
+
+<xsl:template match="glossdiv" mode="auto-glossary-as-blocks">
+  <xsl:param name="terms" select="."/>
+
+  <xsl:variable name="preamble"
+                select="*[not(self::title
+                            or self::subtitle
+                            or self::glossentry)]"/>
+
+  <xsl:apply-templates select="title|subtitle"/>
+  <xsl:apply-templates select="$preamble"/>
+
+  <xsl:for-each select="glossentry">
+    <xsl:variable name="cterm" select="glossterm"/>
+    <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
+      <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
+    </xsl:if>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match="glossentry" mode="auto-glossary-as-blocks">
+  <xsl:apply-templates select="." mode="glossary.as.blocks"/>
 </xsl:template>
 
 <!-- ==================================================================== -->
+<!-- Format glossary as a list -->
+
+<xsl:template match="glossdiv" mode="glossary.as.list">
+  <xsl:param name="width" select="$glossterm.width"/>
+
+  <xsl:variable name="entries" select="glossentry"/>
+  <xsl:variable name="preamble"
+                select="*[not(self::title
+                            or self::subtitle
+                            or self::glossentry)]"/>
+
+  <xsl:apply-templates select="title|subtitle"/>
+
+  <xsl:apply-templates select="$preamble"/>
+
+  <fo:list-block provisional-distance-between-starts="{$width}"
+                 provisional-label-separation="{$glossterm.separation}"
+                 xsl:use-attribute-sets="normal.para.spacing">
+    <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
+  </fo:list-block>
+</xsl:template>
 
 <!--
 GlossEntry ::=
@@ -180,7 +506,7 @@ GlossEntry ::=
   (GlossSee | GlossDef+)
 -->
 
-<xsl:template match="glossentry">
+<xsl:template match="glossentry" mode="glossary.as.list">
   <xsl:variable name="id">
     <xsl:call-template name="object.id"/>
   </xsl:variable>
@@ -195,11 +521,11 @@ GlossEntry ::=
         </xsl:choose>
       </xsl:with-param>
     </xsl:call-template>
-    <xsl:apply-templates/>
+    <xsl:apply-templates mode="glossary.as.list"/>
   </fo:list-item>
 </xsl:template>
 
-<xsl:template match="glossentry/glossterm">
+<xsl:template match="glossentry/glossterm" mode="glossary.as.list">
   <fo:list-item-label end-indent="label-end()">
     <fo:block>
       <xsl:apply-templates/>
@@ -207,16 +533,16 @@ GlossEntry ::=
   </fo:list-item-label>
 </xsl:template>
 
-<xsl:template match="glossentry/acronym">
+<xsl:template match="glossentry/acronym" mode="glossary.as.list">
 </xsl:template>
 
-<xsl:template match="glossentry/abbrev">
+<xsl:template match="glossentry/abbrev" mode="glossary.as.list">
 </xsl:template>
 
-<xsl:template match="glossentry/revhistory">
+<xsl:template match="glossentry/revhistory" mode="glossary.as.list">
 </xsl:template>
 
-<xsl:template match="glossentry/glosssee">
+<xsl:template match="glossentry/glosssee" mode="glossary.as.list">
   <xsl:variable name="otherterm" select="@otherterm"/>
   <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
   <xsl:variable name="target" select="$targets[1]"/>
@@ -231,7 +557,7 @@ GlossEntry ::=
           <xsl:apply-templates select="$target" mode="xref"/>
         </xsl:when>
         <xsl:otherwise>
-          <xsl:apply-templates/>
+          <xsl:apply-templates mode="glossary.as.list"/>
         </xsl:otherwise>
       </xsl:choose>
       <xsl:text>.</xsl:text>
@@ -239,7 +565,7 @@ GlossEntry ::=
   </fo:list-item-body>
 </xsl:template>
 
-<xsl:template match="glossentry/glossdef">
+<xsl:template match="glossentry/glossdef" mode="glossary.as.list">
   <fo:list-item-body start-indent="body-start()">
     <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
     <xsl:if test="glossseealso">
@@ -248,19 +574,20 @@ GlossEntry ::=
           <xsl:with-param name="context" select="'glossary'"/>
           <xsl:with-param name="name" select="'seealso'"/>
         </xsl:call-template>
-        <xsl:apply-templates select="glossseealso"/>
+        <xsl:apply-templates select="glossseealso" mode="glossary.as.list"/>
       </fo:block>
     </xsl:if>
   </fo:list-item-body>
 </xsl:template>
 
-<xsl:template match="glossentry/glossdef/para[1]">
+<xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
+              mode="glossary.as.list">
   <fo:block>
     <xsl:apply-templates/>
   </fo:block>
 </xsl:template>
 
-<xsl:template match="glossseealso">
+<xsl:template match="glossseealso" mode="glossary.as.list">
   <xsl:variable name="otherterm" select="@otherterm"/>
   <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
   <xsl:variable name="target" select="$targets[1]"/>
@@ -270,7 +597,7 @@ GlossEntry ::=
       <xsl:apply-templates select="$target" mode="xref"/>
     </xsl:when>
     <xsl:otherwise>
-      <xsl:apply-templates/>
+      <xsl:apply-templates mode="glossary.as.list"/>
     </xsl:otherwise>
   </xsl:choose>
 
@@ -285,216 +612,119 @@ GlossEntry ::=
 </xsl:template>
 
 <!-- ==================================================================== -->
+<!-- Format glossary blocks -->
 
-<xsl:template match="glossentry" mode="xref">
-  <xsl:apply-templates select="./glossterm[1]" mode="xref"/>
-</xsl:template>
-
-<xsl:template match="glossterm" mode="xref">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id">
-      <xsl:with-param name="object" select="parent::glossentry"/>
-    </xsl:call-template>
-  </xsl:variable>
-
-  <fo:basic-link internal-destination="{$id}"
-                 xsl:use-attribute-sets="xref.properties">
-    <xsl:apply-templates/>
-    <xsl:call-template name="insert.page.citation">
-      <xsl:with-param name="id" select="$id"/>
-    </xsl:call-template>
-  </fo:basic-link>
-</xsl:template>
-
-
-<!-- ==================================================================== -->
-
-<!-- Glossary collection -->
-
-<xsl:template match="glossary[@role='auto']" priority="2">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
-  <xsl:variable name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
-  <xsl:variable name="collection" select="document($glossary.collection, .)"/>
-
+<xsl:template match="glossdiv" mode="glossary.as.blocks">
+  <xsl:variable name="entries" select="glossentry"/>
   <xsl:variable name="preamble"
                 select="*[not(self::title
                             or self::subtitle
-                            or self::glossdiv
                             or self::glossentry)]"/>
 
-  <xsl:if test="$glossary.collection = ''">
-    <xsl:message>
-      <xsl:text>Warning: processing automatic glossary </xsl:text>
-      <xsl:text>without a glossary.collection file.</xsl:text>
-    </xsl:message>
-  </xsl:if>
-
-  <fo:block id="{$id}">
-    <xsl:call-template name="component.separator"/>
-
-    <xsl:call-template name="glossary.titlepage"/>
+  <xsl:apply-templates select="title|subtitle"/>
 
-    <xsl:if test="$preamble">
-      <xsl:apply-templates select="$preamble"/>
-    </xsl:if>
+  <xsl:apply-templates select="$preamble"/>
 
-    <xsl:choose>
-      <xsl:when test="glossdiv and $collection//glossdiv">
-        <xsl:for-each select="$collection//glossdiv">
-          <!-- first see if there are any in this div -->
-          <xsl:variable name="exist.test">
-            <xsl:for-each select="glossentry">
-              <xsl:variable name="cterm" select="glossterm"/>
-              <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
-                <xsl:value-of select="glossterm"/>
-              </xsl:if>
-            </xsl:for-each>
-          </xsl:variable>
-
-          <xsl:if test="$exist.test != ''">
-            <xsl:apply-templates select="." mode="auto-glossary">
-              <xsl:with-param name="terms" select="$terms"/>
-            </xsl:apply-templates>
-          </xsl:if>
-        </xsl:for-each>
-      </xsl:when>
-      <xsl:otherwise>
-        <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                       provisional-label-separation="{$glossterm-sep}"
-                       xsl:use-attribute-sets="normal.para.spacing">
-          <xsl:for-each select="$collection//glossentry">
-            <xsl:variable name="cterm" select="glossterm"/>
-            <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
-              <xsl:apply-templates select="." mode="auto-glossary"/>
-            </xsl:if>
-          </xsl:for-each>
-        </fo:list-block>
-      </xsl:otherwise>
-    </xsl:choose>
-  </fo:block>
+  <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
 </xsl:template>
 
-<xsl:template match="book/glossary[@role='auto']" priority="2.5">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
-  <xsl:variable name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
-  <xsl:variable name="collection" select="document($glossary.collection, .)"/>
-
-  <xsl:variable name="preamble"
-                select="*[not(self::title
-                            or self::subtitle
-                            or self::glossdiv
-                            or self::glossentry)]"/>
+<!--
+GlossEntry ::=
+  GlossTerm, Acronym?, Abbrev?,
+  (IndexTerm)*,
+  RevHistory?,
+  (GlossSee | GlossDef+)
+-->
 
-  <xsl:variable name="master-reference">
-    <xsl:call-template name="select.pagemaster"/>
+<xsl:template match="glossentry" mode="glossary.as.blocks">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
   </xsl:variable>
 
-  <xsl:if test="$glossary.collection = ''">
-    <xsl:message>
-      <xsl:text>Warning: processing automatic glossary </xsl:text>
-      <xsl:text>without a glossary.collection file.</xsl:text>
-    </xsl:message>
-  </xsl:if>
-
-  <fo:page-sequence id="{$id}"
-                    hyphenate="{$hyphenate}"
-                    master-reference="{$master-reference}">
-    <xsl:attribute name="language">
-      <xsl:call-template name="l10n.language"/>
-    </xsl:attribute>
-    <xsl:if test="$double.sided != 0">
-      <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
-    </xsl:if>
-
-    <xsl:apply-templates select="." mode="running.head.mode">
-      <xsl:with-param name="master-reference" select="$master-reference"/>
-    </xsl:apply-templates>
-    <xsl:apply-templates select="." mode="running.foot.mode">
-      <xsl:with-param name="master-reference" select="$master-reference"/>
-    </xsl:apply-templates>
-
-    <fo:flow flow-name="xsl-region-body">
-      <fo:block id="{$id}">
-        <xsl:call-template name="glossary.titlepage"/>
-
-        <xsl:if test="$preamble">
-          <xsl:apply-templates select="$preamble"/>
-        </xsl:if>
-
+  <fo:block xsl:use-attribute-sets="list.block.spacing">
+    <xsl:call-template name="anchor">
+      <xsl:with-param name="conditional">
         <xsl:choose>
-          <xsl:when test="glossdiv and $collection//glossdiv">
-            <xsl:for-each select="$collection//glossdiv">
-              <!-- first see if there are any in this div -->
-              <xsl:variable name="exist.test">
-                <xsl:for-each select="glossentry">
-                  <xsl:variable name="cterm" select="glossterm"/>
-                  <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
-                    <xsl:value-of select="glossterm"/>
-                  </xsl:if>
-                </xsl:for-each>
-              </xsl:variable>
-
-              <xsl:if test="$exist.test != ''">
-                <xsl:apply-templates select="." mode="auto-glossary">
-                  <xsl:with-param name="terms" select="$terms"/>
-                </xsl:apply-templates>
-              </xsl:if>
-            </xsl:for-each>
-          </xsl:when>
-          <xsl:otherwise>
-            <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                           provisional-label-separation="{$glossterm-sep}"
-                           xsl:use-attribute-sets="normal.para.spacing">
-              <xsl:for-each select="$collection//glossentry">
-                <xsl:variable name="cterm" select="glossterm"/>
-                <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
-                  <xsl:apply-templates select="." mode="auto-glossary"/>
-                </xsl:if>
-              </xsl:for-each>
-            </fo:list-block>
-          </xsl:otherwise>
+          <xsl:when test="$glossterm.auto.link != 0
+                          or $glossary.collection != ''">0</xsl:when>
+          <xsl:otherwise>1</xsl:otherwise>
         </xsl:choose>
-      </fo:block>
-    </fo:flow>
-  </fo:page-sequence>
-</xsl:template>
+      </xsl:with-param>
+    </xsl:call-template>
+    <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
+  </fo:block>
 
-<xsl:template match="*" mode="auto-glossary">
-  <!-- pop back out to the default mode for most elements -->
-  <xsl:apply-templates select="."/>
+  <fo:block margin-left="0.25in">
+    <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.blocks"/>
+  </fo:block>
 </xsl:template>
 
-<xsl:template match="glossdiv" mode="auto-glossary">
-  <xsl:param name="terms" select="."/>
+<xsl:template match="glossentry/glossterm" mode="glossary.as.blocks">
+  <fo:inline><xsl:apply-templates/></fo:inline>
+</xsl:template>
 
-  <xsl:variable name="preamble"
-                select="*[not(self::title
-                            or self::subtitle
-                            or self::glossentry)]"/>
+<xsl:template match="glossentry/glosssee" mode="glossary.as.blocks">
+  <xsl:variable name="otherterm" select="@otherterm"/>
+  <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
+  <xsl:variable name="target" select="$targets[1]"/>
 
-  <xsl:apply-templates select="title|subtitle"/>
-  <xsl:apply-templates select="$preamble"/>
-  <fo:list-block provisional-distance-between-starts="{$glossterm-width}"
-                 provisional-label-separation="{$glossterm-sep}"
-                 xsl:use-attribute-sets="normal.para.spacing">
-    <xsl:for-each select="glossentry">
-      <xsl:variable name="cterm" select="glossterm"/>
-      <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
-        <xsl:apply-templates select="." mode="auto-glossary"/>
-      </xsl:if>
-    </xsl:for-each>
-  </fo:list-block>
+  <xsl:call-template name="gentext.template">
+    <xsl:with-param name="context" select="'glossary'"/>
+    <xsl:with-param name="name" select="'see'"/>
+  </xsl:call-template>
+  <xsl:choose>
+    <xsl:when test="@otherterm">
+      <xsl:apply-templates select="$target" mode="xref"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates mode="glossary.as.blocks"/>
+    </xsl:otherwise>
+  </xsl:choose>
+  <xsl:text>.</xsl:text>
 </xsl:template>
 
-<xsl:template match="glossentry" mode="auto-glossary">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
+<xsl:template match="glossentry/glossdef" mode="glossary.as.blocks">
+  <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
+  <xsl:if test="glossseealso">
+    <fo:block>
+      <xsl:call-template name="gentext.template">
+        <xsl:with-param name="context" select="'glossary'"/>
+        <xsl:with-param name="name" select="'seealso'"/>
+      </xsl:call-template>
+      <xsl:apply-templates select="glossseealso" mode="glossary.as.blocks"/>
+    </fo:block>
+  </xsl:if>
+</xsl:template>
 
-  <fo:list-item id="gl.{$id}"
-                xsl:use-attribute-sets="normal.para.spacing">
+<xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
+              mode="glossary.as.blocks">
+  <fo:block>
     <xsl:apply-templates/>
-  </fo:list-item>
+  </fo:block>
+</xsl:template>
+
+<xsl:template match="glossseealso" mode="glossary.as.blocks">
+  <xsl:variable name="otherterm" select="@otherterm"/>
+  <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
+  <xsl:variable name="target" select="$targets[1]"/>
+
+  <xsl:choose>
+    <xsl:when test="@otherterm">
+      <xsl:apply-templates select="$target" mode="xref"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates mode="glossary.as.blocks"/>
+    </xsl:otherwise>
+  </xsl:choose>
+
+  <xsl:choose>
+    <xsl:when test="position() = last()">
+      <xsl:text>.</xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:text>, </xsl:text>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <!-- ==================================================================== -->
index 742e135f1c2af65b4861602de8a8f063ba986015..1df61393a316f6e324d07b9fac5bc9417a6d0d85 100644 (file)
 <!ENTITY generate.index SYSTEM "../params/generate.index.xml">
 <!ENTITY generate.toc SYSTEM "../params/generate.toc.xml">
 <!ENTITY glossary.collection SYSTEM "../params/glossary.collection.xml">
+<!ENTITY glossterm.width SYSTEM "../params/glossterm.width.xml">
+<!ENTITY glossterm.separation SYSTEM "../params/glossterm.separation.xml">
+<!ENTITY glossary.as.blocks SYSTEM "../params/glossary.as.blocks.xml">
+<!ENTITY glosslist.as.blocks SYSTEM "../params/glosslist.as.blocks.xml">
 <!ENTITY glossterm.auto.link SYSTEM "../params/glossterm.auto.link.xml">
 <!ENTITY graphic.default.extension SYSTEM "../params/graphic.default.extension.xml">
 <!ENTITY hyphenate SYSTEM "../params/hyphenate.xml">
index dcd6c7dec0e7d02d261613f5be3d683decfd35b8..e9e69437c33f470893cd0af17f05ac61ff1bd81b 100644 (file)
@@ -173,6 +173,10 @@ generate.section.toc.level;
 &glossterm.auto.link;
 &firstterm.only.link;
 &glossary.collection;
+&glossterm.separation;
+&glossterm.width;
+&glossary.as.blocks;
+&glosslist.as.blocks;
 </reference>
 
 <reference><title>Miscellaneous</title>
@@ -423,8 +427,12 @@ around all these parameters.</para>
 <src:fragref linkend="function.parens.frag"/>
 <src:fragref linkend="generate.index.frag"/>
 <src:fragref linkend="generate.toc.frag"/>
+<src:fragref linkend="glossary.as.blocks.frag"/>
 <src:fragref linkend="glossary.collection.frag"/>
+<src:fragref linkend="glosslist.as.blocks.frag"/>
 <src:fragref linkend="glossterm.auto.link.frag"/>
+<src:fragref linkend="glossterm.separation.frag"/>
+<src:fragref linkend="glossterm.width.frag"/>
 <src:fragref linkend="graphic.default.extension.frag"/>
 <src:fragref linkend="hyphenate.frag"/>
 <src:fragref linkend="informal.object.properties.frag"/>
@@ -459,6 +467,7 @@ around all these parameters.</para>
 <src:fragref linkend="process.empty.source.toc.frag"/>
 <src:fragref linkend="process.source.toc.frag"/>
 <src:fragref linkend="profile.arch.frag"/>
+<src:fragref linkend="profile.attribute.frag"/>
 <src:fragref linkend="profile.condition.frag"/>
 <src:fragref linkend="profile.conformance.frag"/>
 <src:fragref linkend="profile.lang.frag"/>
@@ -467,11 +476,10 @@ around all these parameters.</para>
 <src:fragref linkend="profile.revisionflag.frag"/>
 <src:fragref linkend="profile.role.frag"/>
 <src:fragref linkend="profile.security.frag"/>
+<src:fragref linkend="profile.separator.frag"/>
 <src:fragref linkend="profile.userlevel.frag"/>
-<src:fragref linkend="profile.vendor.frag"/>
-<src:fragref linkend="profile.attribute.frag"/>
 <src:fragref linkend="profile.value.frag"/>
-<src:fragref linkend="profile.separator.frag"/>
+<src:fragref linkend="profile.vendor.frag"/>
 <src:fragref linkend="punct.honorific.frag"/>
 <src:fragref linkend="qanda.inherit.numeration.frag"/>
 <src:fragref linkend="qandadiv.autolabel.frag"/>
@@ -498,20 +506,20 @@ around all these parameters.</para>
 <src:fragref linkend="table.cell.padding.frag"/>
 <src:fragref linkend="table.entry.padding.frag"/>
 <src:fragref linkend="tablecolumns.extension.frag"/>
-<src:fragref linkend="textinsert.extension.frag"/>
-<src:fragref linkend="tex.math.in.alt.frag"/>
 <src:fragref linkend="tex.math.delims.frag"/>
+<src:fragref linkend="tex.math.in.alt.frag"/>
+<src:fragref linkend="textinsert.extension.frag"/>
 <src:fragref linkend="title.font.family.frag"/>
 <src:fragref linkend="title.margin.left.frag"/>
 <src:fragref linkend="toc.indent.width.frag"/>
 <src:fragref linkend="toc.margin.properties.frag"/>
 <src:fragref linkend="toc.section.depth.frag"/>
-<src:fragref linkend="use.extensions.frag"/>
-<src:fragref linkend="use.role.as.xrefstyle.frag"/>
-<src:fragref linkend="use.svg.frag"/>
 <src:fragref linkend="ulink.footnotes.frag"/>
 <src:fragref linkend="ulink.hyphenate.frag"/>
 <src:fragref linkend="ulink.show.frag"/>
+<src:fragref linkend="use.extensions.frag"/>
+<src:fragref linkend="use.role.as.xrefstyle.frag"/>
+<src:fragref linkend="use.svg.frag"/>
 <src:fragref linkend="variablelist.as.blocks.frag"/>
 <src:fragref linkend="verbatim.properties.frag"/>
 <src:fragref linkend="xep.extensions.frag"/>
diff --git a/xsl/params/glossary.as.blocks.xml b/xsl/params/glossary.as.blocks.xml
new file mode 100644 (file)
index 0000000..dd92f05
--- /dev/null
@@ -0,0 +1,33 @@
+<refentry id="glossary.as.blocks">
+<refmeta>
+<refentrytitle>glossary.as.blocks</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>glossary.as.blocks</refname>
+<refpurpose>Present glossarys using blocks instead of lists?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='glossary.as.blocks.frag'>
+<xsl:param name="glossary.as.blocks" select="0"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>If non-zero, <sgmltag>glossary</sgmltag>s will be formatted as
+blocks.</para>
+
+<para>If you have long <sgmltag>glossterm</sgmltag>s, proper list
+markup in the FO case may produce unattractive lists. By setting this
+parameter, you can force the stylesheets to produce block markup
+instead of proper lists.</para>
+
+<para>You can override this setting with a processing instruction as the
+child of <sgmltag>glossary</sgmltag>: <sgmltag class="pi">dbfo
+glossary-presentation="blocks"</sgmltag> or <sgmltag class="pi">dbfo
+glossary-presentation="list"</sgmltag></para>
+
+</refsect1>
+</refentry>
diff --git a/xsl/params/glosslist.as.blocks.xml b/xsl/params/glosslist.as.blocks.xml
new file mode 100644 (file)
index 0000000..53af6ee
--- /dev/null
@@ -0,0 +1,22 @@
+<refentry id="glosslist.as.blocks">
+<refmeta>
+<refentrytitle>glosslist.as.blocks</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>glosslist.as.blocks</refname>
+<refpurpose>Use blocks for glosslists?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='glosslist.as.blocks.frag'>
+<xsl:param name="glosslist.as.blocks" select="0"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>See <parameter>glossary.as.blocks</parameter>.</para>
+
+</refsect1>
+</refentry>
diff --git a/xsl/params/glossterm.separation.xml b/xsl/params/glossterm.separation.xml
new file mode 100644 (file)
index 0000000..d69a2b9
--- /dev/null
@@ -0,0 +1,23 @@
+<refentry id="glossterm.separation">
+<refmeta>
+<refentrytitle>glossterm.separation</refentrytitle>
+<refmiscinfo role="type">length</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>glossterm.separation</refname>
+<refpurpose>Separation between glossary terms and descriptions in list mode</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='glossterm.separation.frag'>
+<xsl:param name="glossterm.separation" select="'0.25in'"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>Specifies the separation between glossary terms and descriptions when
+glossarys are presented using lists.</para>
+
+</refsect1>
+</refentry>
diff --git a/xsl/params/glossterm.width.xml b/xsl/params/glossterm.width.xml
new file mode 100644 (file)
index 0000000..6f26d76
--- /dev/null
@@ -0,0 +1,23 @@
+<refentry id="glossterm.width">
+<refmeta>
+<refentrytitle>glossterm.width</refentrytitle>
+<refmiscinfo role="type">length</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>glossterm.width</refname>
+<refpurpose>Width of glossterm in list presentation mode</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='glossterm.width.frag'>
+<xsl:param name="glossterm.width" select="'2in'"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>This parameter specifies the width reserved for glossary terms when
+a list presentation is used.</para>
+
+</refsect1>
+</refentry>