From d3ac763e13fad090bb55cbb0c33729b16b122261 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Mon, 29 Jan 2024 10:15:58 +0000 Subject: [PATCH 1/5] New glossary tests and test configurations --- .../xsltng/gradle/TestGenerator.groovy | 7 ++ src/test/resources/expected/glossary.001.html | 11 ++- src/test/resources/expected/glossary.002.html | 7 +- src/test/resources/expected/glossary.003.html | 5 +- src/test/resources/expected/glossary.004.html | 6 +- src/test/resources/expected/glossary.005.html | 28 ++++++ src/test/resources/expected/glossary.006.html | 31 +++++++ src/test/resources/expected/glossary.007.html | 23 +++++ src/test/resources/expected/glossary.008.html | 34 +++++++ src/test/resources/expected/glossary.009.html | 32 +++++++ src/test/resources/glosscollection2.xml | 44 ++++++++++ src/test/resources/xml/glossary.001.xml | 14 ++- src/test/resources/xml/glossary.002.xml | 14 ++- src/test/resources/xml/glossary.003.xml | 11 ++- src/test/resources/xml/glossary.004.xml | 11 ++- src/test/resources/xml/glossary.005.xml | 38 ++++++++ src/test/resources/xml/glossary.006.xml | 84 ++++++++++++++++++ src/test/resources/xml/glossary.007.xml | 78 ++++++++++++++++ src/test/resources/xml/glossary.008.xml | 88 +++++++++++++++++++ src/test/resources/xml/glossary.009.xml | 86 ++++++++++++++++++ 20 files changed, 638 insertions(+), 14 deletions(-) create mode 100644 src/test/resources/expected/glossary.005.html create mode 100644 src/test/resources/expected/glossary.006.html create mode 100644 src/test/resources/expected/glossary.007.html create mode 100644 src/test/resources/expected/glossary.008.html create mode 100644 src/test/resources/expected/glossary.009.html create mode 100644 src/test/resources/glosscollection2.xml create mode 100644 src/test/resources/xml/glossary.005.xml create mode 100644 src/test/resources/xml/glossary.006.xml create mode 100644 src/test/resources/xml/glossary.007.xml create mode 100644 src/test/resources/xml/glossary.008.xml create mode 100644 src/test/resources/xml/glossary.009.xml diff --git a/buildSrc/src/main/groovy/org/docbook/xsltng/gradle/TestGenerator.groovy b/buildSrc/src/main/groovy/org/docbook/xsltng/gradle/TestGenerator.groovy index 447666fb77..f0b259bb57 100755 --- a/buildSrc/src/main/groovy/org/docbook/xsltng/gradle/TestGenerator.groovy +++ b/buildSrc/src/main/groovy/org/docbook/xsltng/gradle/TestGenerator.groovy @@ -133,12 +133,17 @@ class TestGenerator { .withEnvironments(['default']) .withStylesheet("${uBuildDir}/xslt/presentation.xsl") + testEnvironments.create('glossary-collection') + .withParameters([ + 'glossary-collection': "${fProjectDir}/src/test/resources/glosscollection.xml"]) + testConfigurations.create('unwrapped').withEnvironments(['unwrap']) testConfigurations.create('transclude').withEnvironments(['transclude']) testConfigurations.create('local').withEnvironments(['local']) testConfigurations.create('colors').withEnvironments(['colors']) testConfigurations.create('ptoc').withEnvironments(['ptoc']) testConfigurations.create('a11y').withEnvironments(['a11y']) + testConfigurations.create('glossary-collection').withEnvironments(['glossary-collection']) def regexList = [] ['fit\\.': 'fit', @@ -149,6 +154,8 @@ class TestGenerator { 'ptoc\\.': 'ptoc', 'mediaobject\\.005': 'a11y', 'presentation\\.': 'presentations', + 'glossary\\.00[1,2,3,4,5,6]': 'glossary-collection', // Not 7, 8, or 9! + 'glossary\\.01': 'glossary-collection', ].each { entry -> Pattern pat = ~"^.*${entry.key}.*\$" regexList.add(new Tuple(pat, testConfigurations.find(entry.value))) diff --git a/src/test/resources/expected/glossary.001.html b/src/test/resources/expected/glossary.001.html index 9ff270f78c..2214ec7512 100644 --- a/src/test/resources/expected/glossary.001.html +++ b/src/test/resources/expected/glossary.001.html @@ -1,8 +1,13 @@ -Unit Test: glossary.001

Unit Test: glossary.001

Wikipedia fruits with pepper

Edited by Someone Random

Just some test data

Chapter 1Fruits and Peppers

There's a firstterm here: +Unit Test: glossary.001

Unit Test: glossary.001

Wikipedia fruits with pepper

Edited by Someone Random

Just some test data

Chapter 1Fruits and Peppers

Note

The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml.

There's a firstterm here: Apple.

And there's a couple of glossterms here: Peach, Jackfruit, -and Durian (not in the Glossary).

We also have Pepper which has two entries in the - glossary. This is wrong, of course. The application should complain.

Glossary

A
Apple

An apple is an edible fruit produced by an apple tree (Malus +and Durian (not in the Glossary).

We also have Pepper which has +two entries in the glossary. This is wrong, of +course. The application should complain. (Note that when constructing a glossary +automatically, repeated terms are avoided by only using the first. When the glossary +is constructed by hand, removing duplicates is the author’s resposibility.)

Glossary

A
Apple

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 diff --git a/src/test/resources/expected/glossary.002.html b/src/test/resources/expected/glossary.002.html index 106b8aa723..6d511458c2 100644 --- a/src/test/resources/expected/glossary.002.html +++ b/src/test/resources/expected/glossary.002.html @@ -1,4 +1,9 @@ -Article wrapper

Article wrapper

This test tests the glossary-collection machinery.

Referencing Apple and Pear.

Glossary

Apple

An apple is an edible fruit produced by an apple tree (Malus +Article wrapper

Article wrapper

Note

The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml.

This test tests the glossary-collection +machinery when the “internal”, auto-generated glossary is +empty.

Referencing Apple and +Pear.

Glossary

Apple

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 diff --git a/src/test/resources/expected/glossary.003.html b/src/test/resources/expected/glossary.003.html index 6002788822..33e3aa34b0 100644 --- a/src/test/resources/expected/glossary.003.html +++ b/src/test/resources/expected/glossary.003.html @@ -1 +1,4 @@ -Article wrapper

Article wrapper

This is a test. Xref to fifo: First-in First-out.

Glossary

first thing

Alphabetically first entry

First-in First-out

Alphabetically second entry

test1

First definition

test2

First definition

Second definition

\ No newline at end of file +Article wrapper

Article wrapper

Note

The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml.

This is a test. Xref to fifo: First-in First-out. The glossary +entries are sorted alphabetically by default.

Glossary

first thing

Alphabetically first entry

First-in First-out

Alphabetically second entry

test1

First definition

test2

First definition

Second definition

\ No newline at end of file diff --git a/src/test/resources/expected/glossary.004.html b/src/test/resources/expected/glossary.004.html index 330ea6d80a..6b1f82a08e 100644 --- a/src/test/resources/expected/glossary.004.html +++ b/src/test/resources/expected/glossary.004.html @@ -1,2 +1,4 @@ -Article wrapper

Article wrapper

This unit test is in response to - issue 171.

Glossary

First-in First-out

Alphabetically second entry

test1

First definition

test2

First definition

Second definition

first thing

Alphabetically first entry

\ No newline at end of file +Article wrapper

Article wrapper

Note

The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml.

This unit test is in response to + issue 171.

Glossary

First-in First-out

Alphabetically first entry

test1

First definition

test2

First definition

Second definition

first thing

Alphabetically fourth entry (sortas=“thing, first”)

\ No newline at end of file diff --git a/src/test/resources/expected/glossary.005.html b/src/test/resources/expected/glossary.005.html new file mode 100644 index 0000000000..c0a5243c37 --- /dev/null +++ b/src/test/resources/expected/glossary.005.html @@ -0,0 +1,28 @@ +Mixed Glossary

Mixed Glossary

Note

The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml.

This test tests the glossary-collection +machinery when the “internal” glossary is not empty. We expect a +glossary with three entries, mixed from the internal and the external +glossaries.

Referencing Apple, +Pear and +Bloodroot.

Glossary

Apple

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 + found today. Apples have been grown for thousands of years in Asia + and Europe and were brought to North America by European + colonists. Apples have religious and mythological significance in + many cultures, including Norse, Greek and European Christian + tradition.

Bloodroot

Sanguinaria canadensis, bloodroot, is a perennial, + herbaceous flowering plant native to eastern North America. It + is the only species in the genus Sanguinaria, included in the + poppy family Papaveraceae, and is most closely related to + Eomecon of eastern Asia.

It is sometimes known as Canada puccoon, bloodwort, + redroot, red puccoon, and black paste. Plants are variable in + leaf and flower shape, and have been separated as a different + subspecies due to these variable shapes, indicating a highly + variable species.

Pear

The pear tree and shrub are a species of genus + 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.

\ No newline at end of file diff --git a/src/test/resources/expected/glossary.006.html b/src/test/resources/expected/glossary.006.html new file mode 100644 index 0000000000..b47658672c --- /dev/null +++ b/src/test/resources/expected/glossary.006.html @@ -0,0 +1,31 @@ +Mixed Glossary with multiple entries

Mixed Glossary with multiple entries

Frank Steimke

Note

The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml.

This test checks the glossary-collection +machinery when the “internal” glossary is not empty, and some +glossterms have definitions in the internal and external glossaries. +The externals glossary file path must be given by setting the +$glossary-collection transformation +parameter.

The internal entry has priority and should therefore +cover/overwrite the definition from the external glossary.

We expect a glossary with four entries, mixed from the internal and the external + glossaries.

  1. Apple should reference the internal, poetic + definition.

  2. Pear references the external definition;

  3. Quince references the internal definition.

  4. Bloodroot references the internal definition.

Glossary

Apple

In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows.

Bloodroot

Sanguinaria canadensis, bloodroot, is a perennial, herbaceous flowering plant + native to eastern North America. It is the only species in the genus + Sanguinaria, included in the poppy family Papaveraceae, and is most closely + related to Eomecon of eastern Asia.

It is sometimes known as Canada puccoon, bloodwort, redroot, red puccoon, and + black paste. Plants are variable in leaf and flower shape, and have been + separated as a different subspecies due to these variable shapes, indicating a + highly variable species.

Pear

The pear tree and shrub are a species of genus + 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.

Quince

The quince (/ˈkwɪns/; Cydonia oblonga) is the sole member of the genus Cydonia + in the Malinae subtribe (which also contains apples and pears, among other + fruits) of the Rosaceae family. It is a deciduous tree that bears hard, aromatic + bright golden-yellow pome fruit, similar in appearance to a pear. Ripe quince + fruits are hard, tart, and astringent. They are eaten raw or processed into + marmalade, jam, paste (known as quince cheese) or alcoholic beverages.

\ No newline at end of file diff --git a/src/test/resources/expected/glossary.007.html b/src/test/resources/expected/glossary.007.html new file mode 100644 index 0000000000..3a3b4ce532 --- /dev/null +++ b/src/test/resources/expected/glossary.007.html @@ -0,0 +1,23 @@ +Mixed Glossary with multiple entries, some from an external glossary

Mixed Glossary with multiple entries, some from an external glossary

Frank Steimke

Note

The test harness is configured to run this test without +setting the glossary-collection parameter.

This test is essentially the same as glossary.006. The difference is, + that the external glossary is referenced by the following processing instruction:

  |<?db glossary-collection='../glosscollection.xml' ?>
+

It checks the glossary-collection machinery when the "internal" + glossary is not empty, and some glossterms have definitions in the internal and external + glossaries. The internal entry has priority and should therefore cover / overwrite the + definition from the external glossary.

We expect a glossary with three entries, mixed from the internal and the external + glossaries.

  1. Apple should reference the internal, poetic + definition.

  2. Pear references the external definition;

  3. Quince references the internal definition.

Glossary

Apple

In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows.

Pear

The pear tree and shrub are a species of genus + 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.

Quince

The quince (/ˈkwɪns/; Cydonia oblonga) is the sole member of the genus Cydonia + in the Malinae subtribe (which also contains apples and pears, among other + fruits) of the Rosaceae family. It is a deciduous tree that bears hard, aromatic + bright golden-yellow pome fruit, similar in appearance to a pear. Ripe quince + fruits are hard, tart, and astringent. They are eaten raw or processed into + marmalade, jam, paste (known as quince cheese) or alcoholic beverages.

\ No newline at end of file diff --git a/src/test/resources/expected/glossary.008.html b/src/test/resources/expected/glossary.008.html new file mode 100644 index 0000000000..718051a468 --- /dev/null +++ b/src/test/resources/expected/glossary.008.html @@ -0,0 +1,34 @@ +Mixed Glossary with multiple entries from two external glossaries

Mixed Glossary with multiple entries from two external glossaries

Frank Steimke

Note

The test harness is configured to run this test without +setting the glossary-collection parameter.

This test is essentially the same as glossary.007. The difference is, + that we have two external glossaries, both referenced by the following processing + instruction:

  |<?db glossary-collection='../glosscollection.xml 
+  |                          ../glosscollection2.xml' ?>
+

It checks the glossary-collection machinery when the "internal" + glossary is not empty, and some glossterms have definitions in the internal and external + glossaries. The internal entry has priority and should therefore cover / overwrite the + definition from the external glossary.

We expect a glossary with three entries, mixed from the internal and the external + glossaries.

  1. Apple should reference the internal, poetic + definition.

  2. Pear references the external definition from + glosscollection;

  3. Cucumber references the external definition from + glosscollection2.

We do not expect an entry for + Quince or Bloodroot in the results document + glossary, although there is an entry in the internal glossary of the input document, because + there is no glossterm or firstterm that references + it.

Glossary

Apple

In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows.

Cucumber

The cucumber (Cucumis sativus) is a widely-cultivated creeping vine plant in the family + Cucurbitaceae that bears cylindrical to spherical fruits, which are used as culinary + vegetables. Considered an annual plant, there are three main types of cucumber—slicing, + pickling, and seedless—within which several cultivars have been created. The cucumber + originates in Asia extending from India, Nepal, Bangladesh, China (Yunnan, Guizhou, + Guangxi), and Northern Thailand, but now grows on most continents, and many different types + of cucumber are grown commercially and traded on the global market. In North America, the + term wild cucumber refers to plants in the genera Echinocystis and Marah, though the two are + not closely related.

Pear

The pear tree and shrub are a species of genus + 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.

\ No newline at end of file diff --git a/src/test/resources/expected/glossary.009.html b/src/test/resources/expected/glossary.009.html new file mode 100644 index 0000000000..da80c78a2d --- /dev/null +++ b/src/test/resources/expected/glossary.009.html @@ -0,0 +1,32 @@ +Referencing a non-existing external glossary

Referencing a non-existing external glossary

Frank Steimke

Note

The test harness is configured to run this test without +setting the glossary-collection parameter.

This test is essentially the same as glossary.008 The difference is, + that we use the following processing instruction, which references one none-existing file + glosscollectionx.xml:

  |<?db glossary-collection='../glosscollection.xml
+  |                          ../glosscollectionx.xml
+  |                          ../glosscollection2.xml' ?>
+

We expect a warning message about the non-existing file, and a glossary with three + entries, mixed from the internal and the external glossaries.

  1. Apple should reference the internal, poetic + definition.

  2. Pear references the external definition from + glosscollection;

  3. Cucumber references the external definition from + glosscollection2.

We do not expect an entry for + Quince or Bloodroot in the results document + glossary, although there is an entry in the internal glossary of the input document, because + there is no glossterm or firstterm that references + it.

Glossary

Apple

In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows.

Cucumber

The cucumber (Cucumis sativus) is a widely-cultivated creeping vine plant in the family + Cucurbitaceae that bears cylindrical to spherical fruits, which are used as culinary + vegetables. Considered an annual plant, there are three main types of cucumber—slicing, + pickling, and seedless—within which several cultivars have been created. The cucumber + originates in Asia extending from India, Nepal, Bangladesh, China (Yunnan, Guizhou, + Guangxi), and Northern Thailand, but now grows on most continents, and many different types + of cucumber are grown commercially and traded on the global market. In North America, the + term wild cucumber refers to plants in the genera Echinocystis and Marah, though the two are + not closely related.

Pear

The pear tree and shrub are a species of genus + 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.

\ No newline at end of file diff --git a/src/test/resources/glosscollection2.xml b/src/test/resources/glosscollection2.xml new file mode 100644 index 0000000000..1fb6808216 --- /dev/null +++ b/src/test/resources/glosscollection2.xml @@ -0,0 +1,44 @@ + + + + + Someone + Random + + + + Wikimedia Commons + + + + + Cucumber + + The cucumber (Cucumis sativus) is a widely-cultivated creeping vine plant in the family + Cucurbitaceae that bears cylindrical to spherical fruits, which are used as culinary + vegetables. Considered an annual plant, there are three main types of cucumber—slicing, + pickling, and seedless—within which several cultivars have been created. The cucumber + originates in Asia extending from India, Nepal, Bangladesh, China (Yunnan, Guizhou, + Guangxi), and Northern Thailand, but now grows on most continents, and many different types + of cucumber are grown commercially and traded on the global market. In North America, the + term wild cucumber refers to plants in the genera Echinocystis and Marah, though the two are + not closely related. + + + + + Bell Pepper + + The bell pepper (also known as sweet pepper, pepper, capsicum /ˈkæpsɪkəm/[1] or in some + places mangoes) is the fruit of plants in the Grossum Group of the species Capsicum annuum. + Cultivars of the plant produce fruits in different colors, including red, yellow, orange, + green, white, chocolate, candy cane striped, and purple. Bell peppers are sometimes grouped + with less pungent chili varieties as "sweet peppers". While they are botanically + fruits—classified as berries—they are commonly used as a vegetable ingredient or side dish. + Other varieties of the genus Capsicum are categorized as chili peppers when they are + cultivated for their pungency, including some varieties of Capsicum annuum. + + + + + diff --git a/src/test/resources/xml/glossary.001.xml b/src/test/resources/xml/glossary.001.xml index f77c1811bb..7774677fdf 100644 --- a/src/test/resources/xml/glossary.001.xml +++ b/src/test/resources/xml/glossary.001.xml @@ -16,6 +16,13 @@ Fruits and Peppers + + +The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml. + + There's a firstterm here: Apple. @@ -23,8 +30,11 @@ Peach, Jackfruit, and Durian (not in the ). -We also have Pepper which has two entries in the - glossary. This is wrong, of course. The application should complain. +We also have Pepper which has +two entries in the glossary. This is wrong, of +course. The application should complain. (Note that when constructing a glossary +automatically, repeated terms are avoided by only using the first. When the glossary +is constructed by hand, removing duplicates is the author’s resposibility.) diff --git a/src/test/resources/xml/glossary.002.xml b/src/test/resources/xml/glossary.002.xml index 7a4293805a..4724aa781f 100644 --- a/src/test/resources/xml/glossary.002.xml +++ b/src/test/resources/xml/glossary.002.xml @@ -2,8 +2,18 @@
Article wrapper -This test tests the glossary-collection machinery. -Referencing Apple and Pear. + +The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml. + + +This test tests the glossary-collection +machinery when the “internal”, auto-generated glossary is +empty. + +Referencing Apple and +Pear. diff --git a/src/test/resources/xml/glossary.003.xml b/src/test/resources/xml/glossary.003.xml index 8d058e4ee3..ffd756a4aa 100644 --- a/src/test/resources/xml/glossary.003.xml +++ b/src/test/resources/xml/glossary.003.xml @@ -1,7 +1,16 @@
Article wrapper - This is a test. Xref to fifo: . + + +The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml. + + + This is a test. Xref to fifo: . The glossary +entries are sorted alphabetically by default. + test1 diff --git a/src/test/resources/xml/glossary.004.xml b/src/test/resources/xml/glossary.004.xml index 59bbdbea3f..4ab33d52df 100644 --- a/src/test/resources/xml/glossary.004.xml +++ b/src/test/resources/xml/glossary.004.xml @@ -3,6 +3,13 @@ xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"> Article wrapper + + +The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml. + + This unit test is in response to issue 171. @@ -26,14 +33,14 @@ FT fthing - Alphabetically first entry + Alphabetically fourth entry (sortas=“thing, first”) First-in First-out FIFO - Alphabetically second entry + Alphabetically first entry diff --git a/src/test/resources/xml/glossary.005.xml b/src/test/resources/xml/glossary.005.xml new file mode 100644 index 0000000000..8d2c7d8408 --- /dev/null +++ b/src/test/resources/xml/glossary.005.xml @@ -0,0 +1,38 @@ + +
+Mixed Glossary + + +The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml. + + +This test tests the glossary-collection +machinery when the “internal” glossary is not empty. We expect a +glossary with three entries, mixed from the internal and the external +glossaries. + +Referencing Apple, +Pear and +Bloodroot. + + + + Bloodroot + + Sanguinaria canadensis, bloodroot, is a perennial, + herbaceous flowering plant native to eastern North America. It + is the only species in the genus Sanguinaria, included in the + poppy family Papaveraceae, and is most closely related to + Eomecon of eastern Asia. + It is sometimes known as Canada puccoon, bloodwort, + redroot, red puccoon, and black paste. Plants are variable in + leaf and flower shape, and have been separated as a different + subspecies due to these variable shapes, indicating a highly + variable species. + + + + +
diff --git a/src/test/resources/xml/glossary.006.xml b/src/test/resources/xml/glossary.006.xml new file mode 100644 index 0000000000..3762e8a16d --- /dev/null +++ b/src/test/resources/xml/glossary.006.xml @@ -0,0 +1,84 @@ + +
+ + Mixed Glossary with multiple entries + + + Frank + Steimke + + + + + +The test harness is configured to run this test with the +glossary-collection parameter pointing to +src/test/resources/glosscollection.xml. + + +This test checks the glossary-collection +machinery when the “internal” glossary is not empty, and some +glossterms have definitions in the internal and external glossaries. +The externals glossary file path must be given by setting the +$glossary-collection transformation +parameter. + +The internal entry has priority and should therefore +cover/overwrite the definition from the external glossary. + + We expect a glossary with four entries, mixed from the internal and the external + glossaries. + + Apple should reference the internal, poetic + definition. + + + Pear references the external definition; + + + Quince references the internal definition. + + + Bloodroot references the internal definition. + + + + + + Quince + + The quince (/ˈkwɪns/; Cydonia oblonga) is the sole member of the genus Cydonia + in the Malinae subtribe (which also contains apples and pears, among other + fruits) of the Rosaceae family. It is a deciduous tree that bears hard, aromatic + bright golden-yellow pome fruit, similar in appearance to a pear. Ripe quince + fruits are hard, tart, and astringent. They are eaten raw or processed into + marmalade, jam, paste (known as quince cheese) or alcoholic beverages. + + + + Apple + + In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows. + + + + Bloodroot + + Sanguinaria canadensis, bloodroot, is a perennial, herbaceous flowering plant + native to eastern North America. It is the only species in the genus + Sanguinaria, included in the poppy family Papaveraceae, and is most closely + related to Eomecon of eastern Asia. + It is sometimes known as Canada puccoon, bloodwort, redroot, red puccoon, and + black paste. Plants are variable in leaf and flower shape, and have been + separated as a different subspecies due to these variable shapes, indicating a + highly variable species. + + + + +
diff --git a/src/test/resources/xml/glossary.007.xml b/src/test/resources/xml/glossary.007.xml new file mode 100644 index 0000000000..46055ae2a7 --- /dev/null +++ b/src/test/resources/xml/glossary.007.xml @@ -0,0 +1,78 @@ + +
+ + + Mixed Glossary with multiple entries, some from an external glossary + + + Frank + Steimke + + + + + +The test harness is configured to run this test without +setting the glossary-collection parameter. + + + This test is essentially the same as glossary.006. The difference is, + that the external glossary is referenced by the following processing instruction: + <?db glossary-collection='../glosscollection.xml' ?> + It checks the glossary-collection machinery when the "internal" + glossary is not empty, and some glossterms have definitions in the internal and external + glossaries. The internal entry has priority and should therefore cover / overwrite the + definition from the external glossary. + We expect a glossary with three entries, mixed from the internal and the external + glossaries. + + Apple should reference the internal, poetic + definition. + + + Pear references the external definition; + + + Quince references the internal definition. + + + + + + Quince + + The quince (/ˈkwɪns/; Cydonia oblonga) is the sole member of the genus Cydonia + in the Malinae subtribe (which also contains apples and pears, among other + fruits) of the Rosaceae family. It is a deciduous tree that bears hard, aromatic + bright golden-yellow pome fruit, similar in appearance to a pear. Ripe quince + fruits are hard, tart, and astringent. They are eaten raw or processed into + marmalade, jam, paste (known as quince cheese) or alcoholic beverages. + + + + Apple + + In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows. + + + + Bloodroot + + Sanguinaria canadensis, bloodroot, is a perennial, herbaceous flowering plant + native to eastern North America. It is the only species in the genus + Sanguinaria, included in the poppy family Papaveraceae, and is most closely + related to Eomecon of eastern Asia. + It is sometimes known as Canada puccoon, bloodwort, redroot, red puccoon, and + black paste. Plants are variable in leaf and flower shape, and have been + separated as a different subspecies due to these variable shapes, indicating a + highly variable species. + + + + +
diff --git a/src/test/resources/xml/glossary.008.xml b/src/test/resources/xml/glossary.008.xml new file mode 100644 index 0000000000..c4774ea920 --- /dev/null +++ b/src/test/resources/xml/glossary.008.xml @@ -0,0 +1,88 @@ + +
+ + + + Mixed Glossary with multiple entries from two external glossaries + + + Frank + Steimke + + + + + +The test harness is configured to run this test without +setting the glossary-collection parameter. + + + This test is essentially the same as glossary.007. The difference is, + that we have two external glossaries, both referenced by the following processing + instruction: + <?db glossary-collection='../glosscollection.xml + ../glosscollection2.xml' ?> + + It checks the glossary-collection machinery when the "internal" + glossary is not empty, and some glossterms have definitions in the internal and external + glossaries. The internal entry has priority and should therefore cover / overwrite the + definition from the external glossary. + We expect a glossary with three entries, mixed from the internal and the external + glossaries. + + Apple should reference the internal, poetic + definition. + + + Pear references the external definition from + glosscollection; + + + Cucumber references the external definition from + glosscollection2. + + We do not expect an entry for + Quince or Bloodroot in the results document + glossary, although there is an entry in the internal glossary of the input document, because + there is no glossterm or firstterm that references + it. + + + + Quince + + The quince (/ˈkwɪns/; Cydonia oblonga) is the sole member of the genus Cydonia + in the Malinae subtribe (which also contains apples and pears, among other + fruits) of the Rosaceae family. It is a deciduous tree that bears hard, aromatic + bright golden-yellow pome fruit, similar in appearance to a pear. Ripe quince + fruits are hard, tart, and astringent. They are eaten raw or processed into + marmalade, jam, paste (known as quince cheese) or alcoholic beverages. + + + + Apple + + In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows. + + + + Bloodroot + + Sanguinaria canadensis, bloodroot, is a perennial, herbaceous flowering plant + native to eastern North America. It is the only species in the genus + Sanguinaria, included in the poppy family Papaveraceae, and is most closely + related to Eomecon of eastern Asia. + It is sometimes known as Canada puccoon, bloodwort, redroot, red puccoon, and + black paste. Plants are variable in leaf and flower shape, and have been + separated as a different subspecies due to these variable shapes, indicating a + highly variable species. + + + + +
diff --git a/src/test/resources/xml/glossary.009.xml b/src/test/resources/xml/glossary.009.xml new file mode 100644 index 0000000000..47335e2709 --- /dev/null +++ b/src/test/resources/xml/glossary.009.xml @@ -0,0 +1,86 @@ + +
+ + + Referencing a non-existing external glossary + + + Frank + Steimke + + + + + +The test harness is configured to run this test without +setting the glossary-collection parameter. + + + This test is essentially the same as glossary.008 The difference is, + that we use the following processing instruction, which references one none-existing file + glosscollectionx.xml: + <?db glossary-collection='../glosscollection.xml + ../glosscollectionx.xml + ../glosscollection2.xml' ?> + + We expect a warning message about the non-existing file, and a glossary with three + entries, mixed from the internal and the external glossaries. + + Apple should reference the internal, poetic + definition. + + + Pear references the external definition from + glosscollection; + + + Cucumber references the external definition from + glosscollection2. + + We do not expect an entry for + Quince or Bloodroot in the results document + glossary, although there is an entry in the internal glossary of the input document, because + there is no glossterm or firstterm that references + it. + + + + Quince + + The quince (/ˈkwɪns/; Cydonia oblonga) is the sole member of the genus Cydonia + in the Malinae subtribe (which also contains apples and pears, among other + fruits) of the Rosaceae family. It is a deciduous tree that bears hard, aromatic + bright golden-yellow pome fruit, similar in appearance to a pear. Ripe quince + fruits are hard, tart, and astringent. They are eaten raw or processed into + marmalade, jam, paste (known as quince cheese) or alcoholic beverages. + + + + Apple + + In early autumn the apple orchards come alive with people and sounds. The + farmers are picking, peeling, and processing apples into everything from apple + pies to apple sauce. Families swarm the apple trees with their baskets looking + for the best Honeycrisp and Macintosh. The sound of children playing is blended + with the occasional barking dog, or the low rumble of the old Ferguson Orchard + tractor pulling a wagon up and down the rows. + + + + Bloodroot + + Sanguinaria canadensis, bloodroot, is a perennial, herbaceous flowering plant + native to eastern North America. It is the only species in the genus + Sanguinaria, included in the poppy family Papaveraceae, and is most closely + related to Eomecon of eastern Asia. + It is sometimes known as Canada puccoon, bloodwort, redroot, red puccoon, and + black paste. Plants are variable in leaf and flower shape, and have been + separated as a different subspecies due to these variable shapes, indicating a + highly variable species. + + + + +
From d166afc98fcc60b035aa28f886dcb8b367b9af6f Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Mon, 29 Jan 2024 10:16:26 +0000 Subject: [PATCH 2/5] Bump the default version of Saxon to 12.4 --- properties.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/properties.gradle b/properties.gradle index 7a9d7c76b0..98f8ecd209 100644 --- a/properties.gradle +++ b/properties.gradle @@ -9,7 +9,7 @@ ext { docbookVersion = '5.2CR5' publishersVersion = '5.2CR5' - saxonVersion = '11.5' + saxonVersion = '12.4' saxonGroup = 'net.sf.saxon' saxonEdition = 'Saxon-HE' //saxonGroup = 'com.saxonica' From d3184ba8a2e3dc2644f5624688a04c24a24bd047 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Mon, 29 Jan 2024 10:25:24 +0000 Subject: [PATCH 3/5] Refactor code to make standalone functions module --- src/main/xslt/modules/functions.xsl | 85 +---------- src/main/xslt/modules/variable.xsl | 4 + src/main/xslt/standalone-functions.xsl | 200 +++++++++++++++++++++++++ 3 files changed, 209 insertions(+), 80 deletions(-) create mode 100644 src/main/xslt/standalone-functions.xsl diff --git a/src/main/xslt/modules/functions.xsl b/src/main/xslt/modules/functions.xsl index 7348300691..52ffce4d8b 100644 --- a/src/main/xslt/modules/functions.xsl +++ b/src/main/xslt/modules/functions.xsl @@ -2,6 +2,7 @@ + + @@ -409,41 +412,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -485,54 +458,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -855,6 +780,6 @@ - - + + diff --git a/src/main/xslt/modules/variable.xsl b/src/main/xslt/modules/variable.xsl index 654597f523..99c91a9ec3 100644 --- a/src/main/xslt/modules/variable.xsl +++ b/src/main/xslt/modules/variable.xsl @@ -26,6 +26,10 @@ + + diff --git a/src/main/xslt/standalone-functions.xsl b/src/main/xslt/standalone-functions.xsl new file mode 100644 index 0000000000..2305284470 --- /dev/null +++ b/src/main/xslt/standalone-functions.xsl @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 10e3ff601b377fbdfdab3882152cf92eb8bbd268 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Mon, 29 Jan 2024 10:25:40 +0000 Subject: [PATCH 4/5] Support automatic glossaries during normalization --- src/main/xslt/transforms/50-normalize.xsl | 98 +++++++---------------- 1 file changed, 30 insertions(+), 68 deletions(-) diff --git a/src/main/xslt/transforms/50-normalize.xsl b/src/main/xslt/transforms/50-normalize.xsl index c771267957..000853e6af 100644 --- a/src/main/xslt/transforms/50-normalize.xsl +++ b/src/main/xslt/transforms/50-normalize.xsl @@ -5,13 +5,14 @@ xmlns:ghost="http://docbook.org/ns/docbook/ghost" xmlns:m="http://docbook.org/ns/docbook/modes" xmlns:mp="http://docbook.org/ns/docbook/modes/private" + xmlns:t="http://docbook.org/ns/docbook/templates" xmlns:tp="http://docbook.org/ns/docbook/templates/private" xmlns:vp="http://docbook.org/ns/docbook/variables/private" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all" version="3.0"> - + @@ -39,24 +40,6 @@ - - - - - - - - - Failed to load $glossary-collection: - - - - - - - - - @@ -183,62 +166,41 @@ - - - - Warning: processing automatic glossary - without an external glossary. - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + From 292a1000ce98757d976ea5f3f32f5038301d7d77 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Mon, 29 Jan 2024 10:25:49 +0000 Subject: [PATCH 5/5] Updated documentation --- src/guide/xml/ch03.xml | 71 +++++++++++++++++++++++++++++++++ src/guide/xml/ref-functions.xml | 33 +++++++++++++++ src/guide/xml/ref-params.xml | 27 +++++++++++-- src/guide/xml/ref-variables.xml | 28 +++++++++++++ src/guide/xsl/common.xsl | 2 +- 5 files changed, 156 insertions(+), 5 deletions(-) diff --git a/src/guide/xml/ch03.xml b/src/guide/xml/ch03.xml index dec642317e..c4a5ba8549 100644 --- a/src/guide/xml/ch03.xml +++ b/src/guide/xml/ch03.xml @@ -675,6 +675,77 @@ This most closely reproduces the numbering from the 1.x stylesheets. +
+Using glossaries + +There are essentially two ways to manage glossaries: you can +author them by hand, or you can build them automatically from a +collection of glossary entries. + +If you build them by hand, if you put glossary elements containing +glossentry elements, etc. in your document, then you have complete control. +What you put in your document is what will be formatted and published. + +If you compose them from glossary collections, only the terms used in your document +(in glossterm or firstterm elements) will appear in the glossary. +The glossary collections can be managed internally or externally. +If multiple definitions appear in the glossary collections, only the first definition +is included. + + The best way to explain automatic glossaries is to use an example. Let's assume that you + have marked the two terms Apple and Pear in your document, so that your automatic glossary should ultimately contain + exactly two entries for these two terms. Create a glossary with + @role='auto' in your document. We call this the internal + glossary. + + + If your internal glossary has three entries for Apple, + Jackfruit and Pear, you will end up with a + glossary in the generated document that has only the two entries for + Apple and Pear. There will be no entry for + Jackfruit, since there is no corresponding glossterm + or firstterm in the main part of your text. + + + You can also use external glossaries for this task, which can be referenced by the use + of the glossary-collection transformation parameter, or the + db processing instruction with a glossary-collection pseudo + attribute. You can leave the internal, automatic glossary completely empty. As long as + there are entries for Apple and Pear in one of + your external gloassries, you will end up with these two entries in the generated + glossary, no matter how much more entries the external glossaries may contain. + + + You can use the internal, automatic glossary in conjunction with external glossaries. + In this case, entries from the internal glossary take precedence over entries for the same + term from external glossaries. Lets say you have entries for Apple + and Pear among others in your external glossary, and also an + glossentry for Apple in your internal glossary. In + this case you will end up with a glossary which contains two entries, one for + Apple with the specific definition taken from the internal + glossary, and one for Pear from the external glossary, which may be a + more general definition. + + + +Schematron rules can help manage the glossary. The +f:glossentries function (defined in +standalone-functions.xsl in the xslTNG install +directory) has been designed so that it can be integrated into +Schematron independently of the xslTNG stylesheets. You can use it to +check whether a corresponding glossentry exists for a +glossterm or firstterm while you are still +writing. Corresponding Schematron schemas are not yet part of the +xslTNG framework. + + + Caveats + The use of glossdiv is not supported for automatic glossaries, all + of the entries will appear in a flat list. + +
+
Creating something completely different diff --git a/src/guide/xml/ref-functions.xml b/src/guide/xml/ref-functions.xml index 7ee63053da..1e623bf176 100644 --- a/src/guide/xml/ref-functions.xml +++ b/src/guide/xml/ref-functions.xml @@ -438,6 +438,39 @@ to construct the divisions in an index. + + + + f:glossentries + {http://docbook.org/ns/docbook/functions}glossentries#1 + {http://docbook.org/ns/docbook/functions}glossentries#2 + + + f:glossentries + Returns a list of all glossentries for a term + function + + + Description + Returns all glossentry elements that are targeted by $term, + which must either by a glossterm or a firstterm element. The + internal glossary of the input document is always taken into account. + In the form with only one argument, external glossaries are also taken into account if + they are designated in the input document with a <?db + glossary-collection='URIs'?> processing instruction. + In the form with two arguments, you can specify a list of URIs of the external + glossaries. + + When there is more than one glossentry found, the result sequence will + start with entries from the internal glossary, if any. + The functions design allows its use indepentend from the xslTNG stylesheets. You can, for + example, integrate it in a Schematron rule that checks whether every glossterm + has exactly one corresponding glossentry while authoring your document. That`s + why the function can't use the glossary-collection transformation + parameter. + + + diff --git a/src/guide/xml/ref-params.xml b/src/guide/xml/ref-params.xml index df089cf9aa..f7efd6df73 100644 --- a/src/guide/xml/ref-params.xml +++ b/src/guide/xml/ref-params.xml @@ -1979,15 +1979,17 @@ across many documents. If glossary-collection points to a glossary, the stylesheets will automatically populate glossary entries in the document being transformed. + To achieve this: + Create a shared glossary and store it somewhere. - - In the document you’re transforming, add an empty glossary with - @role='auto'. - + +In the document you’re transforming, add an empty glossary with +@role='auto'. + Run your transformation with glossary-collection set @@ -1995,7 +1997,24 @@ to the URI of that document. + The stylesheets will copy referenced entries into your document before processing it. + +You may specify per-document glossary collections with the +db + +db processing instruction + processing instruction using the +glossary-collection + +db processing instruction +glossary-collection pseudo-attribute + pseudo-attribute. This must appear in the root element of +your main document. If per-document glossary collections are provided, +they are processed in the order provided before the global +collection. +If multiple definitions for the same term appear in a glossary collection, only +the first term is used. diff --git a/src/guide/xml/ref-variables.xml b/src/guide/xml/ref-variables.xml index a070a70fb1..1eafe3c53e 100644 --- a/src/guide/xml/ref-variables.xml +++ b/src/guide/xml/ref-variables.xml @@ -1733,5 +1733,33 @@ used for a cross-reference. See . + + + +$v:pi-db-attributes-are-uris +{http://docbook.org/ns/docbook/variables}pi-db-attributes-are-uris + + +$v:pi-db-attributes-are-uris +Controls which “db” processing instruction pseudo-attributes are URIs +variable + + +Description +The “db” processing instruction can be used to provide +configuration values within a document. For example: + +]]> + +In this example, xlink-style is just a string value, but +glossary-collection is a URI. +When the value in question is a URI, it must be made absolute against the base URI +of the processing instruction on which it occurs. The v:pi-db-attributes-are-uris +variable determines which pseudo-attributes are considered URIs. Their values are made absolute +when the processing instruction is parsed. + + + + diff --git a/src/guide/xsl/common.xsl b/src/guide/xsl/common.xsl index 312c781428..6077dcee44 100644 --- a/src/guide/xsl/common.xsl +++ b/src/guide/xsl/common.xsl @@ -214,7 +214,7 @@ |$param_xsl//xsl:variable[@name=$dname]"/> - +