]> granicus.if.org Git - docbook-dsssl/commitdiff
Support HTML tables
authorNorman Walsh <ndw@nwalsh.com>
Wed, 27 Aug 2003 14:27:58 +0000 (14:27 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Wed, 27 Aug 2003 14:27:58 +0000 (14:27 +0000)
xsl/html/formal.xsl
xsl/html/table.xsl

index b826169e7c7f98e142140eddc5281a74c27ce16a..686c55cffc0e176b2b1f93e9dafaeca2e4d6d1dc 100644 (file)
   </xsl:choose>
 </xsl:template>
 
-<xsl:template match="table|example">
+<xsl:template match="table">
+  <xsl:choose>
+    <xsl:when test="tgroup|mediaobject|graphic">
+      <xsl:call-template name="calsTable"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:copy-of select="@*"/>
+        <xsl:call-template name="htmlTable"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="calsTable">
   <xsl:variable name="param.placement"
                 select="substring-after(normalize-space($formal.title.placement),
                                         concat(local-name(.), ' '))"/>
   </xsl:call-template>
 </xsl:template>
 
+<xsl:template name="htmlTable">
+  <xsl:apply-templates mode="htmlTable"/>
+</xsl:template>
+
+<xsl:template match="example">
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:call-template name="formal.object">
+    <xsl:with-param name="placement" select="$placement"/>
+    <xsl:with-param name="class" select="local-name(.)"/>
+  </xsl:call-template>
+</xsl:template>
+
 <xsl:template match="equation">
   <xsl:variable name="param.placement"
                 select="substring-after(normalize-space($formal.title.placement),
 </xsl:template>
 
 <xsl:template match="informaltable">
-  <xsl:call-template name="informal.object">
-    <xsl:with-param name="class">
-      <xsl:choose>
-        <xsl:when test="@tabstyle">
-          <xsl:value-of select="@tabstyle"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="local-name(.)"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:with-param>
-  </xsl:call-template>
+  <xsl:choose>
+    <xsl:when test="tgroup|mediaobject|graphic">
+      <xsl:call-template name="informal.object">
+        <xsl:with-param name="class">
+          <xsl:choose>
+            <xsl:when test="@tabstyle">
+              <xsl:value-of select="@tabstyle"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="local-name(.)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <table>
+        <xsl:copy-of select="@*"/>
+        <xsl:call-template name="htmlTable"/>
+      </table>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="informaltable/textobject"></xsl:template>
index 2ec97b60cb26415be87216a1d6c7f101d429d7da..2f649c51d3ad00378b73f4dde6fb734ca70ebf85 100644 (file)
   -->
 </xsl:template>
 
+<!-- ====================================================================== -->
+<!-- HTML Tables -->
+
+<xsl:template match="colgroup" mode="htmlTable">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="htmlTable"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="col" mode="htmlTable">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="caption" mode="htmlTable">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+
+    <xsl:apply-templates select=".." mode="object.title.markup">
+      <xsl:with-param name="allow-anchors" select="1"/>
+    </xsl:apply-templates>
+
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="thead|tbody|tgroup|tr" mode="htmlTable">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="htmlTable"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="th|td" mode="htmlTable">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/> <!-- *not* mode=htmlTable -->
+  </xsl:copy>
+</xsl:template>
+
 </xsl:stylesheet>