[yelp-xsl] db2html-table: Fixed some issues with HTML tables
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-xsl] db2html-table: Fixed some issues with HTML tables
- Date: Sat, 13 Jul 2013 15:36:07 +0000 (UTC)
commit 39114b93e6d691be8defec0c8d4e8ecb12e9df62
Author: Shaun McCance <shaunm gnome org>
Date: Fri Jul 5 13:42:23 2013 -0400
db2html-table: Fixed some issues with HTML tables
xslt/docbook/html/db2html-css.xsl | 8 ++-
xslt/docbook/html/db2html-table.xsl | 176 ++++++++++++++++++++++++++---------
2 files changed, 140 insertions(+), 44 deletions(-)
---
diff --git a/xslt/docbook/html/db2html-css.xsl b/xslt/docbook/html/db2html-css.xsl
index 0448453..074cb98 100644
--- a/xslt/docbook/html/db2html-css.xsl
+++ b/xslt/docbook/html/db2html-css.xsl
@@ -51,7 +51,13 @@ sub sub { font-size: 1em; }
sup { font-size: 0.83em; }
sup sup { font-size: 1em; }
table.table-pgwide { width: 100%; }
-
+table.table-rules-groups thead + *, table.table-rules-rows thead + *,
+table.table-rules-groups tfoot + *, table.table-rules-rows tfoot + *,
+table.table-rules-groups tbody + *, table.table-rules-rows tbody + *,
+table.table-rules-rows tr + * { border-top: solid 1px; }
+table.table-rules-cols td + *, table.table-rules-cols th + * {
+ border-</xsl:text><xsl:value-of select="$left"/><xsl:text>: solid 1px;
+}
td.td-colsep { border-</xsl:text><xsl:value-of select="$right"/><xsl:text>: solid 1px; }
td.td-rowsep { border-bottom: solid 1px; }
diff --git a/xslt/docbook/html/db2html-table.xsl b/xslt/docbook/html/db2html-table.xsl
index 17556be..6bc7bd4 100644
--- a/xslt/docbook/html/db2html-table.xsl
+++ b/xslt/docbook/html/db2html-table.xsl
@@ -993,18 +993,11 @@ REMARK: This template needs to be explained in detail, but I forgot how it works
<xsl:when test="db:tgroup">
<xsl:apply-templates select="db:tgroup"/>
</xsl:when>
- <xsl:when test="tr">
- <xsl:apply-templates select="col | colgroup | tr"/>
- <xsl:apply-templates select="caption"/>
- </xsl:when>
- <xsl:when test="db:tr">
- <xsl:apply-templates select="db:col | db:colgroup | db:tr"/>
- <xsl:apply-templates select="db:caption"/>
- </xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select="thead | db:thead"/>
- <xsl:apply-templates select="tbody | db:tbody"/>
- <xsl:apply-templates select="tfoot | db:tfoot"/>
+ <xsl:call-template name="db2html.table.table">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="table" select="."/>
+ </xsl:call-template>
<xsl:apply-templates select="caption | db:caption"/>
</xsl:otherwise>
</xsl:choose>
@@ -1013,12 +1006,21 @@ REMARK: This template needs to be explained in detail, but I forgot how it works
<!-- = tgroup = -->
<xsl:template match="tgroup | db:tgroup">
+ <xsl:call-template name="db2html.table.table">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="table" select=".."/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="db2html.table.table">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="table" select="$node"/>
<xsl:variable name="colsep">
<xsl:choose>
- <xsl:when test="@colsep">
- <xsl:value-of select="string(@colsep)"/>
+ <xsl:when test="$node/@colsep">
+ <xsl:value-of select="string($node/@colsep)"/>
</xsl:when>
- <xsl:when test="not(.//*[ colsep][1])"/>
+ <xsl:when test="not($node//*[ colsep][1])"/>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
@@ -1026,42 +1028,54 @@ REMARK: This template needs to be explained in detail, but I forgot how it works
</xsl:variable>
<xsl:variable name="rowsep">
<xsl:choose>
- <xsl:when test="@rowsep">
- <xsl:value-of select="string(@rowsep)"/>
+ <xsl:when test="$node/@rowsep">
+ <xsl:value-of select="string($node/@rowsep)"/>
</xsl:when>
- <xsl:when test="not(//*[ rowsep][1])"/>
+ <xsl:when test="not($node//*[ rowsep][1])"/>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="style">
- <xsl:if test="../@frame = 'all' or not(../@frame)">
+ <xsl:if test="$table/@frame = 'all' or $table/@frame = 'border' or not($table/@frame)">
<xsl:text>border: solid 1px; </xsl:text>
</xsl:if>
- <xsl:if test="../@frame = 'none'">
+ <xsl:if test="$table/@frame = 'none'">
<xsl:text>border: none; </xsl:text>
</xsl:if>
- <xsl:if test="../@frame = 'bottom' or ../@frame = 'topbot'">
+ <xsl:if test="$table/@frame = 'bottom' or $table/@frame = 'topbot'">
<xsl:text>border-bottom: solid 1px; </xsl:text>
</xsl:if>
- <xsl:if test="../@frame = 'top' or ../@frame = 'topbot'">
+ <xsl:if test="$table/@frame = 'top' or $table/@frame = 'topbot'">
<xsl:text>border-top: solid 1px; </xsl:text>
</xsl:if>
- <xsl:if test="../@frame = 'sides'">
+ <xsl:if test="$table/@frame = 'sides'">
<xsl:text>border-left: solid 1px; border-right: solid 1px; </xsl:text>
</xsl:if>
</xsl:variable>
<xsl:variable name="class">
- <xsl:if test="../@pgwide = '1'">
+ <xsl:if test="$table/@pgwide = '1'">
<xsl:text>table-pgwide</xsl:text>
</xsl:if>
+ <xsl:if test="$table/@rules = 'groups'">
+ <xsl:text> table-rules-groups</xsl:text>
+ </xsl:if>
+ <xsl:if test="$table/@rules = 'rows'">
+ <xsl:text> table-rules-rows</xsl:text>
+ </xsl:if>
+ <xsl:if test="$table/@rules = 'cols'">
+ <xsl:text> table-rules-cols</xsl:text>
+ </xsl:if>
+ <xsl:if test="$table/@rules = 'all'">
+ <xsl:text> table-rules-rows table-rules-cols</xsl:text>
+ </xsl:if>
</xsl:variable>
<table>
<xsl:call-template name="html.lang.attrs"/>
- <xsl:if test="../title or ../db:title or ../db:info/db:title">
+ <xsl:if test="$table/title or $table/db:title or $table/db:info/db:title">
<xsl:attribute name="summary">
- <xsl:value-of select="../title | ../db:title | ../db:info/db:title"/>
+ <xsl:value-of select="$table/title | $table/db:title | $table/db:info/db:title"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$style != ''">
@@ -1074,24 +1088,36 @@ REMARK: This template needs to be explained in detail, but I forgot how it works
<xsl:value-of select="normalize-space($class)"/>
</xsl:attribute>
</xsl:if>
- <xsl:apply-templates select="thead | db:thead">
- <xsl:with-param name="colspecs" select="colspec | db:colspec"/>
- <xsl:with-param name="spanspecs" select="spanspec | db:spanspec"/>
- <xsl:with-param name="colsep" select="$colsep"/>
- <xsl:with-param name="rowsep" select="$rowsep"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="tbody | db:tbody">
- <xsl:with-param name="colspecs" select="colspec | db:colspec"/>
- <xsl:with-param name="spanspecs" select="spanspec | db:spanspec"/>
- <xsl:with-param name="colsep" select="$colsep"/>
- <xsl:with-param name="rowsep" select="$rowsep"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="tfoot | db:tfoot">
- <xsl:with-param name="colspecs" select="colspec | db:colspec"/>
- <xsl:with-param name="spanspecs" select="spanspec | db:spanspec"/>
- <xsl:with-param name="colsep" select="$colsep"/>
- <xsl:with-param name="rowsep" select="$rowsep"/>
- </xsl:apply-templates>
+ <xsl:choose>
+ <xsl:when test="tr | db:tr">
+ <tbody>
+ <xsl:apply-templates select="$node/tr | $node/db:tr">
+ <xsl:with-param name="colsep" select="$colsep"/>
+ <xsl:with-param name="rowsep" select="$rowsep"/>
+ </xsl:apply-templates>
+ </tbody>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$node/thead | $node/db:thead">
+ <xsl:with-param name="colspecs" select="$node/colspec | $node/db:colspec"/>
+ <xsl:with-param name="spanspecs" select="$node/spanspec | $node/db:spanspec"/>
+ <xsl:with-param name="colsep" select="$colsep"/>
+ <xsl:with-param name="rowsep" select="$rowsep"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="$node/tbody | $node/db:tbody">
+ <xsl:with-param name="colspecs" select="$node/colspec | $node/db:colspec"/>
+ <xsl:with-param name="spanspecs" select="$node/spanspec | $node/db:spanspec"/>
+ <xsl:with-param name="colsep" select="$colsep"/>
+ <xsl:with-param name="rowsep" select="$rowsep"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="$node/tfoot | $node/db:tfoot">
+ <xsl:with-param name="colspecs" select="$node/colspec | $node/db:colspec"/>
+ <xsl:with-param name="spanspecs" select="$node/spanspec | $node/db:spanspec"/>
+ <xsl:with-param name="colsep" select="$colsep"/>
+ <xsl:with-param name="rowsep" select="$rowsep"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
</table>
</xsl:template>
@@ -1137,4 +1163,68 @@ REMARK: This template needs to be explained in detail, but I forgot how it works
</xsl:element>
</xsl:template>
+<!-- = tr = -->
+<xsl:template match="tr | db:tr">
+ <tr>
+ <xsl:call-template name="html.lang.attrs"/>
+ <xsl:choose>
+ <xsl:when test="@align = 'left' or @align = 'center' or
+ @align = 'right' or @align = 'justify' ">
+ <xsl:attribute name="style">
+ <xsl:text>text-align: </xsl:text>
+ <xsl:value-of select="@align"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@align = 'char'">
+ <xsl:attribute name="style">
+ <xsl:text>text-align: "</xsl:text>
+ <xsl:choose>
+ <xsl:when test="@char != ''">
+ <xsl:value-of select="@char"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>.</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"</xsl:text>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates/>
+ </tr>
+</xsl:template>
+
+<!-- = td | th = -->
+<xsl:template match="td | th | db:td | db:th">
+ <xsl:element name="{local-name(.)}" namespace="{$html.namespace}">
+ <xsl:call-template name="html.lang.attrs"/>
+ <xsl:copy-of select="@valign | @rowspan | @colspan"/>
+ <xsl:choose>
+ <xsl:when test="@align = 'left' or @align = 'center' or
+ @align = 'right' or @align = 'justify' ">
+ <xsl:attribute name="style">
+ <xsl:text>text-align: </xsl:text>
+ <xsl:value-of select="@align"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@align = 'char'">
+ <xsl:attribute name="style">
+ <xsl:text>text-align: "</xsl:text>
+ <xsl:choose>
+ <xsl:when test="@char != ''">
+ <xsl:value-of select="@char"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>.</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>"</xsl:text>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates/>
+ </xsl:element>
+</xsl:template>
+
+
</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]