OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Glossary formatting


I had occasion today to sweat a little with an expanding glossary.
Long enough to be clumsy to use without a toc.

This driver provides the minimal toc (A-z as needed)

regards DaveP

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:fo="http://www.w3.org/1999/XSL/Format";
                 version="1.0">


   <xsl:import href="path to your /docbook-xsl-1.62.4/html/docbook.xsl"/>
   <!--  <xsl:include href="/sgml/xsl/book/mytitlepage.xsl"/> -->


   <xsl:param name="glossterm.auto.link" select="1"/>

<xsl:template match="glossary">

   <xsl:call-template name="toc"/>


   <div class="{name(.)}">
     <xsl:if test="$generate.id.attributes != 0">
       <xsl:attribute name="id">
         <xsl:call-template name="object.id"/>
       </xsl:attribute>
     </xsl:if>

     <xsl:call-template name="glossary.titlepage"/>

     <xsl:choose>
       <xsl:when test="glossdiv">
         <xsl:apply-templates select="(glossdiv[1]/preceding-sibling::*)"/>
       </xsl:when>
       <xsl:otherwise>
         <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
       </xsl:otherwise>
     </xsl:choose>

     <xsl:choose>
       <xsl:when test="glossdiv">
         <xsl:apply-templates select="glossdiv"/>
       </xsl:when>
       <xsl:otherwise>
         <dl>
           <xsl:apply-templates select="glossentry"/>
         </dl>
       </xsl:otherwise>
     </xsl:choose>

     <xsl:if test="not(parent::article)">
       <xsl:call-template name="process.footnotes"/>
     </xsl:if>
   </div>
</xsl:template>

<xsl:variable name="uc" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="lc" select="'abcdefghijklmnopqrstuvwxyz'"/>

<xsl:key name="acr" match="glossentry/glossterm"
use="translate(substring(.,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>

<xsl:template name="toc">
   <h3>Table of Contents</h3>
   <xsl:for-each select="glossdiv">
     <ol>

       <xsl:for-each select="glossentry[count(glossterm | key('acr',
    translate (substring(glossterm,1,1),
      'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@',
      'abcdefghijklmnopqrstuvwxyz###########'))[1]) = 1]">

       <li>
         <xsl:variable name="id">
         <xsl:choose>
           <xsl:when test="@id">
             <xsl:value-of select="@id"/>
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="generate-id()"/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
         <a href="#{$id}"><xsl:value-of select="glossterm"/>    </a>
       </li>
     </xsl:for-each>
   </ol>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]