Suppose you want to display the content of your Glossary as a table, to condense the information for one entry on a single line.
<glossgroup> element.<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
exclude-result-prefixes="xs dita2html" version="3.0">
<!-- Create a table that will contain all the glossentries contained in the glossgroup. -->
<xsl:template name="gen-topic">
<xsl:param name="nestlevel" as="xs:integer">
<xsl:choose>
<!-- Limit depth for historical reasons, could allow any depth. -->
<!-- Previously limit was 5. -->
<xsl:when
test="count(ancestor::*[contains(@class, ' topic/topic ')]) > 9"
>9</xsl:when>
<xsl:otherwise>
<xsl:sequence
select="count(ancestor::*[contains(@class, ' topic/topic ')])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:choose>
<xsl:when test="parent::dita and not(preceding-sibling::*)">
<!-- Do not reset xml:lang if it is already set on <html> -->
<!-- Moved outputclass to the body tag -->
<!-- Keep ditaval based styling at this point -->
<!-- (replace DITA-OT 1.6 and earlier call to gen-style) -->
<xsl:apply-templates
select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@style"
mode="add-ditaval-style"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="commonattributes">
<xsl:with-param name="default-output-class"
select="concat('nested', $nestlevel)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="gen-toc-id"/>
<xsl:call-template name="setidaname"/>
<xsl:choose>
<xsl:when test="contains(@class, 'glossgroup/glossgroup')">
<!-- Custom processing for glossgroup. -->
<xsl:apply-templates select="*[contains(@class, 'topic/title')]"/>
<table class="- glossgroup/table table">
<thead class="- glossgroup/thead thead">
<tr class="- glossgroup/row row">
<th class="- glossgroup/entry entry">Acronym</th>
<th class="- glossgroup/entry entry">Term</th>
<th class="- glossgroup/entry entry">Full Term</th>
<xsl:if
test="exists(//*[contains(@class, 'glossentry/glossdef')])">
<th class="- glossgroup/entry entry">Definition</th>
</xsl:if>
</tr>
</thead>
<xsl:apply-templates
select="*[contains(@class, 'glossentry/glossentry')]"/>
</table>
<xsl:apply-templates select="
* except (*[contains(@class, 'topic/title')]
| *[contains(@class, 'glossentry/glossentry')])"/>
</xsl:when>
<xsl:otherwise>
<!-- Default processing. -->
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Create a row for each glossentry. -->
<xsl:template
match="*[contains(@class, 'glossentry/glossentry')]
[parent::*[contains(@class, 'glossgroup/glossgroup')]]">
<xsl:variable name="glossentry" as="node()">
<xsl:next-match/>
</xsl:variable>
<tr>
<xsl:copy-of select="$glossentry/@*"/>
<xsl:copy-of
select="$glossentry/*[contains(@class, 'glossentry/glossAlt')]"/>
<xsl:copy-of
select="$glossentry/*[contains(@class, 'glossentry/glossterm')]"/>
<xsl:copy-of
select="$glossentry/*[contains(@class, 'glossentry/glossSurfaceForm')]"/>
<xsl:copy-of
select="$glossentry/*[contains(@class, 'glossentry/glossdef')]"/>
<xsl:copy-of select="
$glossentry/* except $glossentry/*[contains(@class, 'glossentry/glossAlt')
or contains(@class, 'glossentry/glossterm')
or contains(@class, 'glossentry/glossSurfaceForm')
or contains(@class, 'glossentry/glossdef')]"/>
</tr>
</xsl:template>
<!-- Process only glossBody's children nodes. -->
<xsl:template
match="*[contains(@class, 'glossentry/glossBody')]
[ancestor::*[contains(@class, 'glossgroup/glossgroup')]]">
<xsl:apply-templates/>
</xsl:template>
<!-- Create a cell for each glossterm, glossSurfaceForm and glossAlt. -->
<xsl:template match="
*[contains(@class, 'glossentry/glossterm')]
[ancestor::*[contains(@class, 'glossgroup/glossgroup')]] |
*[contains(@class, 'glossentry/glossSurfaceForm')]
[ancestor::*[contains(@class, 'glossgroup/glossgroup')]] |
*[contains(@class, 'glossentry/glossAlt')]
[ancestor::*[contains(@class, 'glossgroup/glossgroup')]]">
<xsl:variable name="glossContent" as="node()">
<xsl:next-match/>
</xsl:variable>
<td>
<xsl:copy-of select="$glossContent/@*"/>
<xsl:copy-of select="normalize-space(string-join($glossContent//text()))"
/>
</td>
</xsl:template>
<!-- Create a cell for each glossdef. -->
<xsl:template
match="*[contains(@class, 'glossentry/glossdef')]
[ancestor::*[contains(@class, 'glossgroup/glossgroup')]]">
<td>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</td>
</xsl:template>
</xsl:stylesheet>com.oxygenxml.pdf.css.xsl.merged2html5 XSLT extension
point:<publishing-template>
...
<pdf>
...
<xslt>
<extension
id="com.oxygenxml.pdf.css.xsl.merged2html5"
file="xslt/merged2html5Extension.xsl"/>
</xslt>*[class ~= "glossgroup/table"] {
width: 100%;
border: 1px solid black;
border-collapse: collapse;
}
*[class ~= "glossgroup/table"] th {
background-color: lightgray;
}
*[class ~= "glossgroup/table"] th,
*[class ~= "glossgroup/table"] td {
border: 1px solid black;
padding: 0.3em !important;
vertical-align: inherit !important;
}
/* Remove glossSurfaceForm */
th:nth-of-type(3),
*[class ~= "glossentry/glossSurfaceForm"] {
display: none;
}
/* Discard the default glossterm layout */
*[class ~= "glossentry/glossterm"] {
font-size: unset;
font-weight: unset;
}<glossSurfaceForm>
removal part is optional. It is present as an example of how to fully remove a
column.resources
element:<publishing-template>
...
<pdf>
...
<resources>
<css file="css/custom.css"/>
</resources>