Skip to content

Commit

Permalink
Merge pull request #445 from fsteimke/444-multiple-glossentries
Browse files Browse the repository at this point in the history
Prevent crash in case of multiple entries in glossary. Changed description of glossary-collection
  • Loading branch information
ndw authored Jan 16, 2024
2 parents 5b2673f + c2e617c commit 32dacdf
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
17 changes: 6 additions & 11 deletions src/guide/xml/ref-params.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1982,25 +1982,20 @@ entries in the document being transformed.</para>
<para>To achieve this:</para>
<orderedlist>
<listitem>
<para>Create a shared glossary and store it somewhere. Make sure that
each entry in your shared glossary has a unique <att>xml:id</att> value.
</para>
<para>Create a shared glossary and store it somewhere.</para>
</listitem>
<listitem>
<para>In the document you’re transforming, add an empty <code>glossary</code> with
<code>@role='auto'</code>.</para>
</listitem>
<listitem>
<para>Run your
transformation with <parameter>glossary-collection</parameter> set
to the URI of that document.
</para>
</listitem>
<listitem>
<para>In the document you’re transforming, refer to the shared entries
with completely empty <tag>glossentry</tag>
elements that have the same <att>xml:id</att> as an entry in the
shared glossary.
</para>
</listitem>
</orderedlist>
<para>The stylesheets will copy those entries into your document before processing it.</para>
<para>The stylesheets will copy referenced entries into your document before processing it.</para>
</refsection>
</refentry>

Expand Down
2 changes: 1 addition & 1 deletion src/main/xslt/modules/links.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</xsl:if>
<xsl:call-template name="tp:link">
<xsl:with-param name="primary-markup" select="false()"/>
<xsl:with-param name="href" select="f:href(., $target)"/>
<xsl:with-param name="href" select="f:href(., $target[1])"/>
<xsl:with-param name="content" as="item()*">
<xsl:apply-templates/>
</xsl:with-param>
Expand Down
16 changes: 13 additions & 3 deletions src/test/resources/expected/glossary.001.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: glossary.001</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="book division"><header><h1>Unit Test: glossary.001</h1><h2>Wikipedia fruits</h2><div class="editor"><h3><span class="editedby">Edited by </span><span class="first-last personname"><span class="firstname">Someone</span> <span class="surname">Random</span></span></h3></div><p class="releaseinfo"><span class="releaseinfo">Just some test data</span></p></header><div class="list-of-titles"><div class="lot toc"><div class="title">Table of Contents</div><ul class="toc"><li><a href="#R_ch1"><span class="label">1</span><span class="sep"></span>Fruits</a></li><li><a href="#glossary">Glossary</a></li></ul></div></div><section id="R_ch1" class="chapter component"><header><h2>Chapter <span class="label">1</span><span class="sep"></span>Fruits</h2></header><p>There's a <code class="tag tag-element">firstterm</code> here:
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: glossary.001</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="book division"><header><h1>Unit Test: glossary.001</h1><h2>Wikipedia fruits with pepper</h2><div class="editor"><h3><span class="editedby">Edited by </span><span class="first-last personname"><span class="firstname">Someone</span> <span class="surname">Random</span></span></h3></div><p class="releaseinfo"><span class="releaseinfo">Just some test data</span></p></header><div class="list-of-titles"><div class="lot toc"><div class="title">Table of Contents</div><ul class="toc"><li><a href="#R_ch1"><span class="label">1</span><span class="sep"></span>Fruits and Peppers</a></li><li><a href="#glossary">Glossary</a></li></ul></div></div><section id="R_ch1" class="chapter component"><header><h2>Chapter <span class="label">1</span><span class="sep"></span>Fruits and Peppers</h2></header><p>There's a <code class="tag tag-element">firstterm</code> here:
<span class="firstterm"><a href="#apple">Apple</a></span>.</p><p>And there's a couple of <code class="tag tag-element">glossterm</code>s here:
<span class="glossterm"><a href="#peach">Peach</a></span>, <span class="glossterm"><a href="#jackfruit">Jackfruit</a></span>,
and <span class="glossterm">Durian</span> (not in the <a href="#glossary" class="xref xref-glossary">Glossary</a>).</p></section><div id="glossary" class="component glossary"><header><h2>Glossary</h2></header><div id="glossary_gd1" class="glossdiv"><header><div class="title">A</div></header><dl class="glossdiv"><dt id="apple" class="glossentry"><span class="glossterm">Apple</span></dt><dd class="glossdef"><p>An apple is an edible fruit produced by an apple tree (Malus
and <span class="glossterm">Durian</span> (not in the <a href="#glossary" class="xref xref-glossary">Glossary</a>).</p><p>We also have <span class="glossterm"><a href="#glossary_gd5_ge3">Pepper</a></span> which has <em>two</em> entries in the
glossary. This is wrong, of course. The application should complain. </p></section><div id="glossary" class="component glossary"><header><h2>Glossary</h2></header><div id="glossary_gd1" class="glossdiv"><header><div class="title">A</div></header><dl class="glossdiv"><dt id="apple" class="glossentry"><span class="glossterm">Apple</span></dt><dd class="glossdef"><p>An apple is an edible fruit produced by an apple tree (Malus
domestica). Apple trees are cultivated worldwide and are the most
widely grown species in the genus Malus. The tree originated in
Central Asia, where its wild ancestor, Malus sieversii, is still
Expand All @@ -27,4 +28,13 @@
Pyrus, in the family Rosaceae, bearing the pomaceous
fruit of the same name. Several species of pear are valued for
their edible fruit and juices while others are cultivated as
trees.</p></dd><dd><p>See also <a href="#apple"><span class="label">Apple</span></a>.</p></dd></dl></div><dl class="glossary"></dl></div></article></main><nav class="bottom"></nav></body></html>
trees.</p></dd><dd><p>See also <a href="#apple"><span class="label">Apple</span></a>.</p></dd><dt id="glossary_gd5_ge3" class="glossentry"><span class="glossterm">Pepper</span></dt><dd class="glossdef"><p>Black pepper (Piper nigrum) is a flowering vine in the family Piperaceae, cultivated for
its fruit (the peppercorn), which is usually dried and used as a spice and seasoning.
Peppercorns and the ground pepper derived from them may be described simply as pepper,
or more precisely as <em>black pepper</em> (cooked and dried unripe fruit),
<em>green pepper</em> (dried unripe fruit), or <em>white pepper
</em>(ripe fruit seeds).</p></dd><dt id="glossary_gd5_ge4" class="glossentry"><span class="glossterm">Pepper</span></dt><dd class="glossdef"><p>Long pepper (Piper longum), sometimes called Indian long pepper or pippali, is a
flowering vine in the family Piperaceae, cultivated for its fruit, which is usually
dried and used as a spice and seasoning. Long pepper has a taste similar to, but sweeter
and less pungent than, that of its close relative Piper nigrum – from which black, green
and white pepper are obtained. </p></dd></dl></div><dl class="glossary"></dl></div></article></main><nav class="bottom"></nav></body></html>
30 changes: 28 additions & 2 deletions src/test/resources/xml/glossary.001.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
<surname>Random</surname>
</personname>
</editor>
<subtitle>Wikipedia fruits</subtitle>
<subtitle>Wikipedia fruits with pepper</subtitle>
<releaseinfo>Just some test data</releaseinfo>
<othercredit><orgname>Wikimedia Commons</orgname></othercredit>
</info>

<chapter>
<title>Fruits</title>
<title>Fruits and Peppers</title>
<para>There's a <tag>firstterm</tag> here:
<firstterm>Apple</firstterm>.</para>

<para>And there's a couple of <tag>glossterm</tag>s here:
<glossterm>Peach</glossterm>, <glossterm>Jackfruit</glossterm>,
and <glossterm>Durian</glossterm> (not in the <xref linkend="glossary"/>).</para>

<para>We also have <glossterm>Pepper</glossterm> which has <emphasis>two</emphasis> entries in the
glossary. This is wrong, of course. The application should complain. </para>
</chapter>

<glossary xml:id="glossary">
Expand Down Expand Up @@ -121,6 +124,29 @@ and <glossterm>Durian</glossterm> (not in the <xref linkend="glossary"/>).</para
<glossseealso otherterm="apple">Apples</glossseealso>
</glossdef>
</glossentry>

<glossentry>
<glossterm>Pepper</glossterm>
<glossdef>
<para>Black pepper (Piper nigrum) is a flowering vine in the family Piperaceae, cultivated for
its fruit (the peppercorn), which is usually dried and used as a spice and seasoning.
Peppercorns and the ground pepper derived from them may be described simply as pepper,
or more precisely as <emphasis>black pepper</emphasis> (cooked and dried unripe fruit),
<emphasis>green pepper</emphasis> (dried unripe fruit), or <emphasis>white pepper
</emphasis>(ripe fruit seeds).</para>
</glossdef>
</glossentry>

<glossentry>
<glossterm>Pepper</glossterm>
<glossdef>
<para>Long pepper (Piper longum), sometimes called Indian long pepper or pippali, is a
flowering vine in the family Piperaceae, cultivated for its fruit, which is usually
dried and used as a spice and seasoning. Long pepper has a taste similar to, but sweeter
and less pungent than, that of its close relative Piper nigrum – from which black, green
and white pepper are obtained. </para>
</glossdef>
</glossentry>
</glossdiv>

</glossary>
Expand Down

0 comments on commit 32dacdf

Please sign in to comment.