]> granicus.if.org Git - docbook-dsssl/commitdiff
Add support for colspan and rowspan and bgcolor in td and th
authorBob Stayton <bobs@sagehill.net>
Wed, 1 Apr 2009 00:05:10 +0000 (00:05 +0000)
committerBob Stayton <bobs@sagehill.net>
Wed, 1 Apr 2009 00:05:10 +0000 (00:05 +0000)
elements in HTML table markup.

xsl/fo/htmltbl.xsl

index 1954d956b2c49a99d66dd49c04b6f08221e0f6e2..14f0105ba4c054141c4a14cd279113ed7d9749ba 100644 (file)
 </xsl:template>
 
 <xsl:template match="td" mode="htmlTable">
-  <xsl:variable name="bgcolor">
+  <xsl:variable name="bgcolor.pi">
     <xsl:call-template name="pi.dbfo_bgcolor"/>
   </xsl:variable>
+  <xsl:variable name="bgcolor">
+    <xsl:choose>
+      <xsl:when test="$bgcolor.pi != ''">
+        <xsl:value-of select="$bgcolor.pi"/>
+      </xsl:when>
+      <xsl:when test="string-length(@bgcolor) != 0">
+        <xsl:value-of select="@bgcolor"/>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:variable>
   <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
     <xsl:call-template name="table.cell.properties">
       <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
       <xsl:with-param name="rowsep.inherit" select="0"/>
       <xsl:with-param name="colsep.inherit" select="0"/>
     </xsl:call-template>
+
+    <xsl:if test="@colspan &gt; 1">
+      <xsl:attribute name="number-columns-spanned">
+        <xsl:value-of select="@colspan"/>
+      </xsl:attribute>
+    </xsl:if>
+
+    <xsl:if test="@rowspan &gt; 1">
+      <xsl:attribute name="number-rows-spanned">
+        <xsl:value-of select="@rowspan"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <fo:block>
       <xsl:call-template name="table.cell.block.properties"/>
       <xsl:apply-templates/>
 </xsl:template>
 
 <xsl:template match="th" mode="htmlTable">
-  <xsl:variable name="bgcolor">
+  <xsl:variable name="bgcolor.pi">
     <xsl:call-template name="pi.dbfo_bgcolor"/>
   </xsl:variable>
+  <xsl:variable name="bgcolor">
+    <xsl:choose>
+      <xsl:when test="$bgcolor.pi != ''">
+        <xsl:value-of select="$bgcolor.pi"/>
+      </xsl:when>
+      <xsl:when test="string-length(@bgcolor) != 0">
+        <xsl:value-of select="@bgcolor"/>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:variable>
   <fo:table-cell xsl:use-attribute-sets="th.style table.cell.padding">
+
     <xsl:call-template name="table.cell.properties">
       <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
       <xsl:with-param name="rowsep.inherit" select="0"/>
       <xsl:with-param name="colsep.inherit" select="0"/>
     </xsl:call-template>
+
+    <xsl:if test="@colspan &gt; 1">
+      <xsl:attribute name="number-columns-spanned">
+        <xsl:value-of select="@colspan"/>
+      </xsl:attribute>
+    </xsl:if>
+
+    <xsl:if test="@rowspan &gt; 1">
+      <xsl:attribute name="number-rows-spanned">
+        <xsl:value-of select="@rowspan"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <fo:block>
       <xsl:call-template name="table.cell.block.properties"/>
       <xsl:apply-templates/>