]> granicus.if.org Git - docbook-dsssl/commitdiff
Table support improvements
authorNorman Walsh <ndw@nwalsh.com>
Tue, 16 Oct 2001 18:03:23 +0000 (18:03 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Tue, 16 Oct 2001 18:03:23 +0000 (18:03 +0000)
xsl/common/table.xsl
xsl/fo/table.xsl
xsl/html/table.xsl

index 895e92da3e35735681172f22e1a7c9af3b30fdf1..65f6fef2083619fadb10b1dde81141f0e865ebde 100644 (file)
@@ -183,29 +183,26 @@ or 0 (the empty string)</para>
                       select="$entry/ancestor::tgroup/colspec[@colname=$namest]"/>
     </xsl:call-template>
   </xsl:variable>
+
   <xsl:variable name="ecol">
     <xsl:call-template name="colspec.colnum">
       <xsl:with-param name="colspec"
                       select="$entry/ancestor::tgroup/colspec[@colname=$nameend]"/>
     </xsl:call-template>
   </xsl:variable>
-  <xsl:value-of select="$ecol - $scol + 1"/>
-</xsl:template>
-
-<xsl:template name="X.calculate.rowsep">
-  <xsl:param name="entry" select="."/>
-  <xsl:param name="colnum" select="0"/>
 
   <xsl:choose>
-    <xsl:when test="$entry/ancestor::table/@frame = 'all'
-                    or $entry/ancestor::informaltable/@frame = 'all'">1</xsl:when>
-    <xsl:when test="$entry/@rowsep">
-      <xsl:value-of select="$entry/@rowsep"/>
-    </xsl:when>
-    <xsl:when test="$entry/ancestor::row[1]/@rowsep">
-      <xsl:value-of select="$entry/ancestor::row[1]/@rowsep"/>
+    <xsl:when test="$namest != '' and $nameend != ''">
+      <xsl:choose>
+        <xsl:when test="$ecol &gt;= $scol">
+          <xsl:value-of select="$ecol - $scol + 1"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$scol - $ecol + 1"/>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:when>
-    <xsl:otherwise>0</xsl:otherwise>
+    <xsl:otherwise>1</xsl:otherwise>
   </xsl:choose>
 </xsl:template>
 
@@ -213,6 +210,17 @@ or 0 (the empty string)</para>
   <xsl:param name="entry" select="."/>
   <xsl:param name="colnum" select="0"/>
 
+  <xsl:call-template name="inherited.table.attribute">
+    <xsl:with-param name="entry" select="$entry"/>
+    <xsl:with-param name="colnum" select="$colnum"/>
+    <xsl:with-param name="attribute" select="'rowsep'"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="X.calculate.rowsep">
+  <xsl:param name="entry" select="."/>
+  <xsl:param name="colnum" select="0"/>
+
 <!--
   <xsl:text>[</xsl:text>
   <xsl:value-of select="$colnum"/>
@@ -279,6 +287,17 @@ or 0 (the empty string)</para>
   <xsl:param name="entry" select="."/>
   <xsl:param name="colnum" select="0"/>
 
+  <xsl:call-template name="inherited.table.attribute">
+    <xsl:with-param name="entry" select="$entry"/>
+    <xsl:with-param name="colnum" select="$colnum"/>
+    <xsl:with-param name="attribute" select="'colsep'"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="X.calculate.colsep">
+  <xsl:param name="entry" select="."/>
+  <xsl:param name="colnum" select="0"/>
+
 <!--
   <xsl:text>[</xsl:text>
   <xsl:value-of select="$colnum"/>
@@ -341,6 +360,123 @@ or 0 (the empty string)</para>
   </xsl:choose>
 </xsl:template>
 
+<xsl:template name="inherited.table.attribute">
+  <xsl:param name="entry" select="."/>
+  <xsl:param name="colnum" select="0"/>
+  <xsl:param name="attribute" select="'colsep'"/>
+
+  <xsl:variable name="entry.value">
+    <xsl:call-template name="get-attribute">
+      <xsl:with-param name="element" select="$entry"/>
+      <xsl:with-param name="attribute" select="$attribute"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="row.value">
+    <xsl:call-template name="get-attribute">
+      <xsl:with-param name="element" select="$entry/ancestor::row[1]"/>
+      <xsl:with-param name="attribute" select="$attribute"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="span.value">
+    <xsl:if test="$entry/@spanname">
+      <xsl:variable name="spanname" select="$entry/@spanname"/>
+      <xsl:variable name="spanspec"
+                    select="$entry/ancestor::tgroup/spanspec[@spanname=$spanname]"/>
+      <xsl:variable name="span.colspec"
+                    select="$entry/ancestor::tgroup/colspec[@colname=$spanspec/@namest]"/>
+
+      <xsl:variable name="spanspec.value">
+        <xsl:call-template name="get-attribute">
+          <xsl:with-param name="element" select="$spanspec"/>
+          <xsl:with-param name="attribute" select="$attribute"/>
+        </xsl:call-template>
+      </xsl:variable>
+
+      <xsl:variable name="scolspec.value">
+        <xsl:call-template name="get-attribute">
+          <xsl:with-param name="element" select="$span.colspec"/>
+          <xsl:with-param name="attribute" select="$attribute"/>
+        </xsl:call-template>
+      </xsl:variable>
+
+      <xsl:choose>
+        <xsl:when test="$spanspec.value != ''">
+          <xsl:value-of select="$spanspec.value"/>
+        </xsl:when>
+        <xsl:when test="$scolspec.value != ''">
+          <xsl:value-of select="$scolspec.value"/>
+        </xsl:when>
+        <xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:variable>
+
+  <xsl:variable name="namest.value">
+    <xsl:if test="$entry/@namest">
+      <xsl:variable name="namest" select="$entry/@namest"/>
+      <xsl:variable name="colspec"
+                    select="$entry/ancestor::tgroup/colspec[@colname=$namest]"/>
+
+      <xsl:variable name="namest.value">
+        <xsl:call-template name="get-attribute">
+          <xsl:with-param name="element" select="$colspec"/>
+          <xsl:with-param name="attribute" select="$attribute"/>
+        </xsl:call-template>
+      </xsl:variable>
+
+      <xsl:choose>
+        <xsl:when test="$namest.value">
+          <xsl:value-of select="$namest.value"/>
+        </xsl:when>
+        <xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:variable>
+
+  <xsl:variable name="tgroup.value">
+    <xsl:call-template name="get-attribute">
+      <xsl:with-param name="element" select="$entry/ancestor::tgroup[1]"/>
+      <xsl:with-param name="attribute" select="$attribute"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$entry.value != ''">
+      <xsl:value-of select="$entry.value"/>
+    </xsl:when>
+    <xsl:when test="$row.value != ''">
+      <xsl:value-of select="$row.value"/>
+    </xsl:when>
+    <xsl:when test="$span.value">
+      <xsl:value-of select="$span.value"/>
+    </xsl:when>
+    <xsl:when test="$namest.value">
+      <xsl:value-of select="$namest.value"/>
+    </xsl:when>
+    <xsl:when test="$colnum &gt; 0">
+      <xsl:variable name="calc.colvalue">
+        <xsl:call-template name="colnum.colspec">
+          <xsl:with-param name="colnum" select="$colnum"/>
+          <xsl:with-param name="attribute" select="$attribute"/>
+        </xsl:call-template>
+      </xsl:variable>
+      <xsl:choose>
+        <xsl:when test="$calc.colvalue != ''">
+          <xsl:value-of select="$calc.colvalue"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$tgroup.value"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$tgroup.value"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <xsl:template name="colnum.colspec">
   <xsl:param name="colnum" select="0"/>
   <xsl:param name="attribute" select="'colname'"/>
index a684812973f91c88353b5b45617b3d2b3114a506..a6625289303b4848867345eec004e1836ead06a2 100644 (file)
@@ -62,16 +62,18 @@ to be incomplete. Don't forget to read the source, too :-)</para>
   <xsl:param name="colnum" select="0"/>
 
   <xsl:variable name="rowsep">
-    <xsl:call-template name="calculate.rowsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
       <xsl:with-param name="colnum" select="$colnum"/>
+      <xsl:with-param name="attribute" select="'rowsep'"/>
     </xsl:call-template>
   </xsl:variable>
 
   <xsl:variable name="colsep">
-    <xsl:call-template name="calculate.colsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
       <xsl:with-param name="colnum" select="$colnum"/>
+      <xsl:with-param name="attribute" select="'colsep'"/>
     </xsl:call-template>
   </xsl:variable>
 
@@ -93,13 +95,11 @@ to be incomplete. Don't forget to read the source, too :-)</para>
       </xsl:call-template>
     </xsl:if>
     <fo:block>
-      <!--
       <xsl:text>e(</xsl:text>
       <xsl:value-of select="$rowsep"/>
       <xsl:text>,</xsl:text>
       <xsl:value-of select="$colsep"/>
       <xsl:text>)</xsl:text>
-      -->
     </fo:block>
   </fo:table-cell>
 </xsl:template>
@@ -406,16 +406,50 @@ to be incomplete. Don't forget to read the source, too :-)</para>
   </xsl:variable>
 
   <xsl:variable name="rowsep">
-    <xsl:call-template name="calculate.rowsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="."/>
       <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'rowsep'"/>
     </xsl:call-template>
   </xsl:variable>
 
   <xsl:variable name="colsep">
-    <xsl:call-template name="calculate.colsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="."/>
       <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'colsep'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="valign">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'valign'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="align">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'align'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="char">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'char'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="charoff">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'charoff'"/>
     </xsl:call-template>
   </xsl:variable>
 
@@ -490,35 +524,42 @@ to be incomplete. Don't forget to read the source, too :-)</para>
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="@valign">
+        <xsl:if test="$valign != ''">
           <xsl:attribute name="display-align">
             <xsl:choose>
-              <xsl:when test="@valign='top'">before</xsl:when>
-              <xsl:when test="@valign='middle'">center</xsl:when>
-              <xsl:when test="@valign='bottom'">after</xsl:when>
+              <xsl:when test="$valign='top'">before</xsl:when>
+              <xsl:when test="$valign='middle'">center</xsl:when>
+              <xsl:when test="$valign='bottom'">after</xsl:when>
+              <xsl:otherwise>
+                <xsl:message>
+                  <xsl:text>Unexpected valign value: </xsl:text>
+                  <xsl:value-of select="$valign"/>
+                  <xsl:text>, center used.</xsl:text>
+                </xsl:message>
+                <xsl:text>center</xsl:text>
+              </xsl:otherwise>
             </xsl:choose>
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="@align">
+        <xsl:if test="$align != ''">
           <xsl:attribute name="text-align">
-            <xsl:value-of select="@align"/>
+            <xsl:value-of select="$align"/>
           </xsl:attribute>
         </xsl:if>
 
-<!--
-        <xsl:if test="@char">
-          <xsl:attribute name="char">
-            <xsl:value-of select="@char"/>
+        <xsl:if test="$char != ''">
+          <xsl:attribute name="text-align">
+            <xsl:value-of select="$char"/>
           </xsl:attribute>
         </xsl:if>
 
+<!--
         <xsl:if test="@charoff">
           <xsl:attribute name="charoff">
             <xsl:value-of select="@charoff"/>
           </xsl:attribute>
         </xsl:if>
-
 -->
 
         <fo:block>
index 2931a217b1c6032c8e5f76f02847fcff97e56cd9..72125d80579fd8365b30e3581af4c98388513088 100644 (file)
   <xsl:param name="colnum" select="0"/>
 
   <xsl:variable name="rowsep">
-    <xsl:call-template name="calculate.rowsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
       <xsl:with-param name="colnum" select="$colnum"/>
+      <xsl:with-param name="attribute" select="'rowsep'"/>
     </xsl:call-template>
   </xsl:variable>
 
   <xsl:variable name="colsep">
-    <xsl:call-template name="calculate.colsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
       <xsl:with-param name="colnum" select="$colnum"/>
+      <xsl:with-param name="attribute" select="'colsep'"/>
     </xsl:call-template>
   </xsl:variable>
 
   </xsl:variable>
 
   <xsl:variable name="rowsep">
-    <xsl:call-template name="calculate.rowsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="."/>
       <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'rowsep'"/>
     </xsl:call-template>
   </xsl:variable>
 
   <xsl:variable name="colsep">
-    <xsl:call-template name="calculate.colsep">
+    <xsl:call-template name="inherited.table.attribute">
       <xsl:with-param name="entry" select="."/>
       <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'colsep'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="valign">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'valign'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="align">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'align'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="char">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'char'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="charoff">
+    <xsl:call-template name="inherited.table.attribute">
+      <xsl:with-param name="entry" select="."/>
+      <xsl:with-param name="colnum" select="$entry.colnum"/>
+      <xsl:with-param name="attribute" select="'charoff'"/>
     </xsl:call-template>
   </xsl:variable>
 
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="@align">
+        <xsl:if test="$align != ''">
           <xsl:attribute name="align">
-            <xsl:value-of select="@align"/>
+            <xsl:value-of select="$align"/>
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="@char">
-          <xsl:attribute name="char">
-            <xsl:value-of select="@char"/>
+        <xsl:if test="$valign != ''">
+          <xsl:attribute name="valign">
+            <xsl:value-of select="$valign"/>
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="@charoff">
-          <xsl:attribute name="charoff">
-            <xsl:value-of select="@charoff"/>
+        <xsl:if test="$char != ''">
+          <xsl:attribute name="char">
+            <xsl:value-of select="$char"/>
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="@valign">
-          <xsl:attribute name="valign">
-            <xsl:value-of select="@valign"/>
+        <xsl:if test="$charoff != ''">
+          <xsl:attribute name="charoff">
+            <xsl:value-of select="$charoff"/>
           </xsl:attribute>
         </xsl:if>
 
-        <xsl:if test="not(preceding-sibling::*)
-                      and ancestor::row/@id">
+        <xsl:if test="not(preceding-sibling::*) and ancestor::row/@id">
           <xsl:call-template name="anchor">
             <xsl:with-param name="node" select="ancestor::row[1]"/>
           </xsl:call-template>
   <xsl:param name="cols" select="1"/>
   <xsl:param name="count" select="1"/>
   <xsl:choose>
-    <xsl:when test="$count>$cols"></xsl:when>
+    <xsl:when test="$count &gt; $cols"></xsl:when>
     <xsl:otherwise>
       <xsl:call-template name="generate.col">
         <xsl:with-param name="countcol" select="$count"/>