]> granicus.if.org Git - docbook-dsssl/commitdiff
fix issue #59 man: mishandles footnotes in tables
authorbobstayton <bobs@sagehill.net>
Fri, 20 Jul 2018 20:07:22 +0000 (13:07 -0700)
committerbobstayton <bobs@sagehill.net>
Fri, 20 Jul 2018 20:48:49 +0000 (13:48 -0700)
xsl/manpages/table.xsl
xsl/manpages/tbl.xsl

index 020b66543b82b45d44cd5b2193585c031cf1ee05..a8db79540f2bf225fc33b863d08f75aaf58712b0 100644 (file)
           <xsl:for-each select="descendant-or-self::d:table|descendant-or-self::d:informaltable">
             <xsl:element name="{local-name(..)}">
               <table>
-                <xsl:apply-templates mode="stripNS" select="*"/>
+                <!-- strip namespace from docbook HTML table markup if present -->
+                <xsl:apply-templates mode="strip.html.table.ns" select="*"/>
+                <xsl:if test=".//d:footnote|../d:title//d:footnote">
+                  <tbody class="footnotes">
+                    <tr>
+                      <td colspan="{@cols}">
+                        <xsl:apply-templates select=".//d:footnote|../d:title//d:footnote" mode="table.footnote.mode"/>
+                      </td>
+                    </tr>
+                  </tbody>
+                </xsl:if>
               </table>
             </xsl:element>
           </xsl:for-each>
     </xsl:call-template>
   </xsl:template>
 
+<!-- strip namespace only from docbook html markup elements -->
+<xsl:template match="d:tbody
+                    |d:caption
+                    |d:col
+                    |d:colgroup
+                    |d:thead
+                    |d:tfoot
+                    |d:tr
+                    |d:th
+                    |d:td" mode="strip.html.table.ns">
+  <xsl:element name="{local-name(.)}">
+    <xsl:copy-of select="@*[not(name(.) = 'xml:id')
+                            and not(name(.) = 'version')]"/>
+    <xsl:if test="@xml:id">
+      <xsl:attribute name="id">
+        <xsl:value-of select="@xml:id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates mode="strip.html.table.ns"/>
+  </xsl:element>
+</xsl:template>
+
+<!-- do not strip namespace from cell contents -->
+<xsl:template match="*|text()|processing-instruction()|comment()" mode="strip.html.table.ns">
+  <!-- process in normal mode -->
+  <xsl:apply-templates select="."/>
+  <!--
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="strip.html.table.ns"/>
+  </xsl:copy>
+  -->
+</xsl:template>
+
 </xsl:stylesheet>
index 4693f03bbd4946e73c909476faad9b27d4eff828..1261e35d15f68ad7ba35c1e9191b357eee49b874 100755 (executable)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <xsl:stylesheet 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:d="http://docbook.org/ns/docbook"
   xmlns:exsl="http://exslt.org/common"
   exclude-result-prefixes="exsl"
   version="1.0">
@@ -11,10 +12,14 @@ The HTML comes either from an HTML-markup table in the source,
 stripped of docbook namespace if necessary, or from applying
 the stock DocBook HTML templates to a CALS table. -->
 
+<!--
 <xsl:import href="../common/stripns.xsl"/>
+-->
 
 <xsl:template match="*" mode="fix.namespace">
+  <!--
   <xsl:apply-templates select="." mode="stripNS"/>
+  -->
 </xsl:template>
 
 
@@ -481,10 +486,10 @@ the stock DocBook HTML templates to a CALS table. -->
   <!-- * ============================================================== -->
   <!-- *    table footnotes                                      -->
   <!-- * ============================================================== -->
-  <xsl:template match="footnote" mode="table.footnote.mode">
-    <xsl:variable name="footnotes" select=".//footnote"/>
+  <xsl:template match="d:footnote" mode="table.footnote.mode">
+    <xsl:variable name="footnotes" select=".//d:footnote"/>
     <xsl:variable name="table.footnotes"
-                  select=".//tgroup//footnote"/>
+                  select=".//tgroup//d:footnote"/>
     <xsl:value-of select="$man.table.footnotes.divider"/>
     <xsl:text>&#10;</xsl:text>
     <xsl:text>.br&#10;</xsl:text>
@@ -495,21 +500,9 @@ the stock DocBook HTML templates to a CALS table. -->
   <!-- * The following template for footnote.body.number mode was just -->
   <!-- * lifted from the HTML stylesheets with some minor adjustments -->
   <xsl:template match="*"  mode="footnote.body.number">
-    <xsl:variable name="name">
-      <xsl:text>ftn.</xsl:text>
-      <xsl:call-template name="object.id">
-        <xsl:with-param name="object" select="ancestor::footnote"/>
-      </xsl:call-template>
-    </xsl:variable>
-    <xsl:variable name="href">
-      <xsl:text>#</xsl:text>
-      <xsl:call-template name="object.id">
-        <xsl:with-param name="object" select="ancestor::footnote"/>
-      </xsl:call-template>
-    </xsl:variable>
     <xsl:variable name="footnote.mark">
       <xsl:text>[</xsl:text>
-      <xsl:apply-templates select="ancestor::footnote"
+      <xsl:apply-templates select="ancestor::d:footnote"
                            mode="footnote.number"/>
       <xsl:text>]&#10;</xsl:text>
     </xsl:variable>
@@ -538,9 +531,9 @@ the stock DocBook HTML templates to a CALS table. -->
     </xsl:choose>
   </xsl:template>
 
-  <!-- * The HTML stylesheets output <sup><a>...</a></sup> around -->
+  <!-- * The HTML stylesheets output <a><sup>...</sup></a> around -->
   <!-- * footnote markers in tables -->
-  <xsl:template match="th/sup">
+  <xsl:template match="a/sup">
     <xsl:apply-templates/>
   </xsl:template>
   <xsl:template match="a">