</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: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:if test="$preamble">
+ <xsl:apply-templates select="$preamble"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$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: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)]"/>
+
+ <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">
+ <fo:block id="{$id}">
+ <xsl:call-template name="glossary.titlepage"/>
+
+ <xsl:if test="$preamble">
+ <xsl:apply-templates select="$preamble"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="$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>
+ </fo:flow>
+ </fo:page-sequence>
+</xsl:template>
+
+<xsl:template match="*" mode="auto-glossary">
+ <!-- pop back out to the default mode for most elements -->
+ <xsl:apply-templates select="."/>
+</xsl:template>
+
+<xsl:template match="glossdiv" mode="auto-glossary">
+ <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"/>
+ <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:template>
+
+<xsl:template match="glossentry" mode="auto-glossary">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <fo:list-item id="gl.{$id}"
+ xsl:use-attribute-sets="normal.para.spacing">
+ <xsl:apply-templates/>
+ </fo:list-item>
+</xsl:template>
+
<!-- ==================================================================== -->
</xsl:stylesheet>
</xsl:template>
<xsl:template match="firstterm">
- <xsl:call-template name="inline.italicseq"/>
+ <xsl:call-template name="glossterm">
+ <xsl:with-param name="firstterm" select="1"/>
+ </xsl:call-template>
</xsl:template>
-<xsl:template match="glossterm">
+<xsl:template match="glossterm" name="glossterm">
+ <xsl:param name="firstterm" select="0"/>
+
<xsl:choose>
- <xsl:when test="@linkend">
+ <xsl:when test="($firstterm.only.link = 0 or $firstterm = 1) and @linkend">
<fo:basic-link internal-destination="{@linkend}"
xsl:use-attribute-sets="xref.properties">
<xsl:call-template name="inline.charseq"/>
</fo:basic-link>
</xsl:when>
- <xsl:when test="$glossterm.auto.link != 0">
+ <xsl:when test="not(@linkend)
+ and ($firstterm.only.link = 0 or $firstterm = 1)
+ and $glossary.collection != ''">
+ <xsl:variable name="term">
+ <xsl:choose>
+ <xsl:when test="@baseform"><xsl:value-of select="@baseform"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="cterm"
+ select="(document($glossary.collection,.)//glossentry[glossterm=$term])[1]"/>
+
+ <xsl:choose>
+ <xsl:when test="not($cterm)">
+ <xsl:message>
+ <xsl:text>There's no entry for </xsl:text>
+ <xsl:value-of select="$term"/>
+ <xsl:text> in </xsl:text>
+ <xsl:value-of select="$glossary.collection"/>
+ </xsl:message>
+ <xsl:call-template name="inline.italicseq"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="id">
+ <xsl:text>gl.</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$cterm/@id">
+ <xsl:value-of select="$cterm/@id"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="generate-id($cterm)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <fo:basic-link internal-destination="{$id}"
+ xsl:use-attribute-sets="xref.properties">
+ <xsl:call-template name="inline.italicseq"/>
+ </fo:basic-link>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test="not(@linkend)
+ and ($firstterm.only.link = 0 or $firstterm = 1)
+ and $glossterm.auto.link != 0">
<xsl:variable name="term">
<xsl:choose>
<xsl:when test="@baseform">
<!ENTITY default.units SYSTEM "../params/default.units.xml">
<!ENTITY dingbat.font.family SYSTEM "../params/dingbat.font.family.xml">
<!ENTITY double.sided SYSTEM "../params/double.sided.xml">
+<!ENTITY firstterm.only.link SYSTEM "../params/firstterm.only.link.xml">
<!ENTITY footnote.font.size SYSTEM "../params/footnote.font.size.xml">
<!ENTITY fop.extensions SYSTEM "../params/fop.extensions.xml">
<!ENTITY formal.object.properties SYSTEM "../params/formal.object.properties.xml">
<!ENTITY generate.division.toc SYSTEM "../params/generate.division.toc.xml">
<!ENTITY generate.index SYSTEM "../params/generate.index.xml">
<!ENTITY generate.set.toc SYSTEM "../params/generate.set.toc.xml">
+<!ENTITY glossary.collection SYSTEM "../params/glossary.collection.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">
&qanda.inherit.numeration;
</reference>
-<reference><title>Linking</title>
-&glossterm.auto.link;
-</reference>
-
<reference><title>Bibliography</title>
&biblioentry.item.separator;
&bibliography.collection;
</reference>
+<reference><title>Glossary</title>
+&glossterm.auto.link;
+&firstterm.only.link;
+&glossary.collection;
+</reference>
+
<reference><title>Miscellaneous</title>
&graphic.default.extension;
&formal.procedures;
<src:fragref linkend="default.units.frag"/>
<src:fragref linkend="dingbat.font.family.frag"/>
<src:fragref linkend="double.sided.frag"/>
+<src:fragref linkend="firstterm.only.link.frag"/>
<src:fragref linkend="footnote.font.size.frag"/>
<src:fragref linkend="fop.extensions.frag"/>
<src:fragref linkend="formal.object.properties.frag"/>
<src:fragref linkend="generate.division.toc.frag"/>
<src:fragref linkend="generate.index.frag"/>
<src:fragref linkend="generate.set.toc.frag"/>
+<src:fragref linkend="glossary.collection.frag"/>
<src:fragref linkend="glossterm.auto.link.frag"/>
<src:fragref linkend="graphic.default.extension.frag"/>
<src:fragref linkend="hyphenate.frag"/>
<!-- ==================================================================== -->
+<!-- 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: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>
+
+ <div id="{$id}" class="{name(.)}">
+ <xsl:call-template name="glossary.titlepage"/>
+
+ <xsl:choose>
+ <xsl:when test="$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>
+ <dl>
+ <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>
+ </dl>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="process.footnotes"/>
+ </div>
+</xsl:template>
+
+<xsl:template match="*" mode="auto-glossary">
+ <!-- pop back out to the default mode for most elements -->
+ <xsl:apply-templates select="."/>
+</xsl:template>
+
+<xsl:template match="glossdiv" mode="auto-glossary">
+ <xsl:param name="terms" select="."/>
+
+ <div class="{name(.)}">
+ <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
+
+ <dl>
+ <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>
+ </dl>
+ </div>
+</xsl:template>
+
+<xsl:template match="glossentry" mode="auto-glossary">
+ <xsl:apply-templates mode="auto-glossary"/>
+</xsl:template>
+
+<xsl:template match="glossentry/glossterm[1]" priority="2" mode="auto-glossary">
+ <xsl:variable name="id">
+ <xsl:text>gl.</xsl:text>
+ <xsl:call-template name="object.id">
+ <xsl:with-param name="object" select=".."/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <dt>
+ <a name="{$id}"/>
+ <xsl:apply-templates/>
+ </dt>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
</xsl:stylesheet>
</xsl:template>
<xsl:template match="firstterm">
- <xsl:call-template name="inline.italicseq"/>
+ <xsl:call-template name="glossterm">
+ <xsl:with-param name="firstterm" select="1"/>
+ </xsl:call-template>
</xsl:template>
-<xsl:template match="glossterm">
+<xsl:template match="glossterm" name="glossterm">
+ <xsl:param name="firstterm" select="0"/>
+
<xsl:choose>
- <xsl:when test="@linkend">
+ <xsl:when test="($firstterm.only.link = 0 or $firstterm = 1) and @linkend">
<xsl:variable name="targets" select="key('id',@linkend)"/>
<xsl:variable name="target" select="$targets[1]"/>
</a>
</xsl:when>
- <xsl:when test="$glossterm.auto.link != 0">
+ <xsl:when test="not(@linkend)
+ and ($firstterm.only.link = 0 or $firstterm = 1)
+ and $glossary.collection != ''">
+ <xsl:variable name="term">
+ <xsl:choose>
+ <xsl:when test="@baseform"><xsl:value-of select="@baseform"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="cterm"
+ select="(document($glossary.collection,.)//glossentry[glossterm=$term])[1]"/>
+
+ <xsl:choose>
+ <xsl:when test="not($cterm)">
+ <xsl:message>
+ <xsl:text>There's no entry for </xsl:text>
+ <xsl:value-of select="$term"/>
+ <xsl:text> in </xsl:text>
+ <xsl:value-of select="$glossary.collection"/>
+ </xsl:message>
+ <xsl:call-template name="inline.italicseq"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="id">
+ <xsl:text>gl.</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$cterm/@id">
+ <xsl:value-of select="$cterm/@id"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="generate-id($cterm)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <a href="#{$id}">
+ <xsl:call-template name="inline.italicseq"/>
+ </a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test="not(@linkend)
+ and ($firstterm.only.link = 0 or $firstterm = 1)
+ and $glossterm.auto.link != 0">
<xsl:variable name="term">
<xsl:choose>
<xsl:when test="@baseform">
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
- <xsl:variable name="targets"
+ <xsl:variable name="targets"
select="//glossentry[glossterm=$term or glossterm/@baseform=$term]"/>
<xsl:variable name="target" select="$targets[1]"/>
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
-
+
<xsl:attribute name="href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$target"/>
</xsl:call-template>
</xsl:attribute>
-
+
<xsl:call-template name="inline.italicseq"/>
</a>
</xsl:otherwise>
<!ENTITY ebnf.table.bgcolor SYSTEM "../params/ebnf.table.bgcolor.xml">
<!ENTITY ebnf.table.border SYSTEM "../params/ebnf.table.border.xml">
<!ENTITY emphasis.propagates.style SYSTEM "../params/emphasis.propagates.style.xml">
+<!ENTITY firstterm.only.link SYSTEM "../params/firstterm.only.link.xml">
<!ENTITY formal.procedures SYSTEM "../params/formal.procedures.xml">
<!ENTITY funcsynopsis.decoration SYSTEM "../params/funcsynopsis.decoration.xml">
<!ENTITY funcsynopsis.style SYSTEM "../params/funcsynopsis.style.xml">
<!ENTITY generate.section.toc SYSTEM "../params/generate.section.toc.xml">
<!ENTITY generate.section.toc.level SYSTEM "../params/generate.section.toc.level.xml">
<!ENTITY generate.set.toc SYSTEM "../params/generate.set.toc.xml">
+<!ENTITY glossary.collection SYSTEM "../params/glossary.collection.xml">
<!ENTITY glossterm.auto.link SYSTEM "../params/glossterm.auto.link.xml">
<!ENTITY graphic.default.extension SYSTEM "../params/graphic.default.extension.xml">
<!ENTITY html.base SYSTEM "../params/html.base.xml">
&olink.pubid;
&olink.sysid;
&olink.resolver;
-&glossterm.auto.link;
</reference>
<reference><title>Bibliography</title>
&bibliography.collection;
</reference>
+<reference><title>Glossary</title>
+&glossterm.auto.link;
+&firstterm.only.link;
+&glossary.collection;
+</reference>
+
<reference><title>Miscellaneous</title>
&graphic.default.extension;
&formal.procedures;
<src:fragref linkend="ebnf.table.bgcolor.frag"/>
<src:fragref linkend="ebnf.table.border.frag"/>
<src:fragref linkend="emphasis.propagates.style.frag"/>
+<src:fragref linkend="firstterm.only.link.frag"/>
<src:fragref linkend="formal.procedures.frag"/>
<src:fragref linkend="funcsynopsis.decoration.frag"/>
<src:fragref linkend="funcsynopsis.style.frag"/>
<src:fragref linkend="generate.section.toc.frag"/>
<src:fragref linkend="generate.section.toc.level.frag"/>
<src:fragref linkend="generate.set.toc.frag"/>
+<src:fragref linkend="glossary.collection.frag"/>
<src:fragref linkend="glossterm.auto.link.frag"/>
<src:fragref linkend="graphic.default.extension.frag"/>
<src:fragref linkend="html.base.frag"/>
--- /dev/null
+<refentry id="firstterm.only.link">
+<refmeta>
+<refentrytitle>firstterm.only.link</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>firstterm.only.link</refname>
+<refpurpose>Does automatic glossterm linking only apply to firstterms?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='firstterm.only.link.frag'>
+<xsl:param name="firstterm.only.link" select="0"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>If true, only <sgmltag>firstterm</sgmltag>s will be automatically linked
+to the glossary. If glossary linking is not enabled, this parameter
+has no effect.</para>
+
+</refsect1>
+</refentry>
--- /dev/null
+<refentry id="glossary.collection">
+<refmeta>
+<refentrytitle>glossary.collection</refentrytitle>
+<refmiscinfo role="type">string</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>glossary.collection</refname>
+<refpurpose>Name of the glossary collection file</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='glossary.collection.frag'>
+<xsl:param name="glossary.collection" select="''"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>Tired of manually maintaining glossaries for multiple documents?
+Now you can maintain a central glossary and let the stylesheets do
+the copying for you. This parameter identifies the file (by URI reference)
+that contains your complete glossary collection.
+</para>
+
+<para>THIS IS EXPERIMENTAL. IT PROBABLY DOESN'T WORK</para>
+
+</refsect1>
+</refentry>