From: <nw...@us...> - 2008-07-18 12:32:40
|
Revision: 8090 http://docbook.svn.sourceforge.net/docbook/?rev=8090&view=rev Author: nwalsh Date: 2008-07-18 12:32:33 +0000 (Fri, 18 Jul 2008) Log Message: ----------- Attempt to make literllayout and CALS tables sort-of work Modified Paths: -------------- trunk/xsl2/base/fo/docbook.xsl trunk/xsl2/base/fo/verbatim.xsl trunk/xsl2/base/html/autoidx.xsl Added Paths: ----------- trunk/xsl2/base/fo/table.xsl Modified: trunk/xsl2/base/fo/docbook.xsl =================================================================== --- trunk/xsl2/base/fo/docbook.xsl 2008-07-18 11:29:59 UTC (rev 8089) +++ trunk/xsl2/base/fo/docbook.xsl 2008-07-18 12:32:33 UTC (rev 8090) @@ -38,9 +38,7 @@ <xsl:include href="pi.xsl"/> <xsl:include href="info.xsl"/> <xsl:include href="glossary.xsl"/> -<!-- <xsl:include href="table.xsl"/> ---> <xsl:include href="lists.xsl"/> <!-- <xsl:include href="task.xsl"/> Added: trunk/xsl2/base/fo/table.xsl =================================================================== --- trunk/xsl2/base/fo/table.xsl (rev 0) +++ trunk/xsl2/base/fo/table.xsl 2008-07-18 12:32:33 UTC (rev 8090) @@ -0,0 +1,206 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:db="http://docbook.org/ns/docbook" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + xmlns:f="http://docbook.org/xslt/ns/extension" + xmlns:ghost="http://docbook.org/ns/docbook/ephemeral" + xmlns:h="http://www.w3.org/1999/xhtml" + xmlns:m="http://docbook.org/xslt/ns/mode" + xmlns:t="http://docbook.org/xslt/ns/template" + xmlns:u="http://nwalsh.com/xsl/unittests#" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="db doc f ghost h m t u xs" + version="2.0"> + +<xsl:param name="table.width.nominal" select="'6.5in'"/> + +<xsl:include href="../common/table.xsl"/> + +<xsl:template match="db:table"> + <fo:block> + <xsl:choose> + <xsl:when test="db:tgroup|db:mediaobject"> + <xsl:apply-templates select="db:tgroup|db:mediaobject"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="." mode="m:html"/> + </xsl:otherwise> + </xsl:choose> + </fo:block> +</xsl:template> + +<xsl:template match="db:informaltable"> + <fo:block> + <xsl:choose> + <xsl:when test="db:tgroup|db:mediaobject"> + <xsl:apply-templates select="db:tgroup|db:mediaobject"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="." mode="m:html"> + </xsl:apply-templates> + </xsl:otherwise> + </xsl:choose> + </fo:block> +</xsl:template> + +<xsl:template name="t:table-longdesc"> + <!-- NOP --> +</xsl:template> + +<!-- ============================================================ --> +<!-- CALS tables --> + +<xsl:template match="db:tgroup"> + <xsl:if test="not(@cols) or @cols = ''"> + <xsl:message terminate="yes"> + <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text> + </xsl:message> + </xsl:if> + + <!-- We used to do a two-phase process here, phase1 is now part of + normalization. Otherwise xref's in the table were in the "wrong tree" + when we came to processing the entries --> + + <xsl:apply-templates select="." mode="m:cals"/> +</xsl:template> + +<xsl:template match="db:tgroup" name="db:tgroup" mode="m:cals"> + <xsl:variable name="summary" + select="f:pi(processing-instruction('dbhtml'),'table-summary')"/> + + <xsl:variable name="cellspacing" + select="f:pi(processing-instruction('dbhtml'),'cellspacing')"/> + + <xsl:variable name="cellpadding" + select="f:pi(processing-instruction('dbhtml'),'cellpadding')"/> + + <fo:table> + <xsl:if test="../@pgwide=1 or self::db:entrytbl"> + <xsl:attribute name="width" select="'100%'"/> + </xsl:if> + + <!-- FIXME: handle frame --> + <!-- FIXME: handle table width --> + + <xsl:apply-templates select="db:thead" mode="m:cals"/> + <xsl:apply-templates select="db:tfoot" mode="m:cals"/> + <xsl:apply-templates select="db:tbody" mode="m:cals"/> + </fo:table> +</xsl:template> + +<xsl:template match="db:entrytbl" mode="m:cals"> + <fo:table-cell> + <xsl:call-template name="db:tgroup"/> + </fo:table-cell> +</xsl:template> + +<!-- ============================================================ --> + +<doc:mode name="m:cals" xmlns="http://docbook.org/ns/docbook"> +<refpurpose>Mode for processing normalized CALS tables</refpurpose> + +<refdescription> +<para>This mode is used to format normalized CALS tables.</para> +</refdescription> +</doc:mode> + +<xsl:template match="db:thead" mode="m:cals"> + <fo:table-header> + <xsl:apply-templates mode="m:cals"/> + </fo:table-header> +</xsl:template> + +<xsl:template match="db:tbody" mode="m:cals"> + <fo:table-body> + <xsl:apply-templates mode="m:cals"/> + </fo:table-body> +</xsl:template> + +<xsl:template match="db:tfoot" mode="m:cals"> + <fo:table-footer> + <xsl:apply-templates mode="m:cals"/> + </fo:table-footer> +</xsl:template> + +<xsl:template match="db:colspec|db:spanspec" mode="m:cals"> + <!-- nop --> +</xsl:template> + +<xsl:template match="db:row" mode="m:cals"> + <fo:table-row> + <xsl:apply-templates mode="m:cals"/> + </fo:table-row> +</xsl:template> + +<xsl:template match="db:entry" mode="m:cals"> + <xsl:variable name="empty.cell" select="not(node())"/> + + <fo:table-cell> + <!-- FIXME: handle @revisionflag --> + <xsl:if test="@ghost:morerows > 0"> + <xsl:attribute name="number-rows-spanned" select="@ghost:morerows + 1"/> + </xsl:if> + + <xsl:if test="@ghost:width > 1"> + <xsl:attribute name="number-columns-spanned" select="@ghost:width"/> + </xsl:if> + + <fo:block> + <xsl:choose> + <xsl:when test="$empty.cell"> + <xsl:text> </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </fo:block> + </fo:table-cell> +</xsl:template> + +<xsl:template match="ghost:empty" mode="m:cals"> + <!-- FIXME: what about attributes on empty cells? --> + <table-cell/> +</xsl:template> + +<xsl:template match="ghost:overlapped" mode="m:cals"> + <!-- nop --> +</xsl:template> + +<xsl:template match="*" mode="m:cals"> + <xsl:message terminate="yes"> + <xsl:text>Error: attempt to process </xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text> in mode m:cals.</xsl:text> + </xsl:message> +</xsl:template> + +<xsl:template match="comment()|processing-instruction()|text()" + mode="m:cals"> + <xsl:copy/> +</xsl:template> + +<!-- ============================================================ --> +<!-- HTML tables --> + +<doc:mode name="m:html" xmlns="http://docbook.org/ns/docbook"> +<refpurpose>Mode for processing HTML tables</refpurpose> + +<refdescription> +<para>This mode is used to format HTML tables.</para> +<para>FIXME: don't copy non-HTML attributes if there are any!</para> +</refdescription> +</doc:mode> + +<xsl:template match="db:table|db:caption|db:col|db:colgroup + |db:thead|db:tfoot|db:tbody|db:tr + |db:th|db:td" mode="m:html"> + <xsl:message terminate="yes">HTML tables not supported yet.</xsl:message> +</xsl:template> + +<xsl:template match="db:informaltable" mode="m:html"> + <xsl:message terminate="yes">HTML tables not supported yet.</xsl:message> +</xsl:template> + +</xsl:stylesheet> Modified: trunk/xsl2/base/fo/verbatim.xsl =================================================================== --- trunk/xsl2/base/fo/verbatim.xsl 2008-07-18 11:29:59 UTC (rev 8089) +++ trunk/xsl2/base/fo/verbatim.xsl 2008-07-18 12:32:33 UTC (rev 8090) @@ -93,24 +93,28 @@ </xsl:choose> </xsl:template> -<xsl:template match="db:literallayout" +<xsl:template match="db:literallayout|db:address" mode="m:verbatim"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="id" select="f:node-id(.)"/> - <div class="{local-name(.)}"> - <xsl:call-template name="id"/> - <xsl:apply-templates mode="mp:literallayout"/> - </div> + <xsl:choose> + <xsl:when test="$shade.verbatim != 0"> + <fo:block id="{$id}" + xsl:use-attribute-sets="verbatim.properties + shade.verbatim.style"> + <xsl:apply-templates mode="m:verbatim"/> + </fo:block> + </xsl:when> + <xsl:otherwise> + <fo:block id="{$id}" + xsl:use-attribute-sets="verbatim.properties"> + <xsl:apply-templates mode="m:verbatim"/> + </fo:block> + </xsl:otherwise> + </xsl:choose> </xsl:template> -<xsl:template match="db:address" - mode="m:verbatim"> - - <div class="{local-name(.)}"> - <xsl:call-template name="id"/> - <xsl:apply-templates mode="mp:literallayout"/> - </div> -</xsl:template> - <!-- <xsl:template match="ghost:co"> <xsl:if test="@xml:id"> Modified: trunk/xsl2/base/html/autoidx.xsl =================================================================== --- trunk/xsl2/base/html/autoidx.xsl 2008-07-18 11:29:59 UTC (rev 8089) +++ trunk/xsl2/base/html/autoidx.xsl 2008-07-18 12:32:33 UTC (rev 8090) @@ -117,13 +117,15 @@ <xsl:value-of select="f:group-label($group-index, $lang)"/> </h3> <dl> - <xsl:apply-templates select="$nodes" mode="m:index-primary"> - <xsl:sort select="&primary;" lang="{$lang}"/> - <xsl:with-param name="scope" select="$scope"/> - <xsl:with-param name="role" select="$role"/> - <xsl:with-param name="type" select="$type"/> - <xsl:with-param name="lang" select="$lang"/> - </xsl:apply-templates> + <xsl:for-each-group select="$nodes" group-by="&primary;"> + <xsl:sort select="&primary;" lang="{$lang}"/> + <xsl:apply-templates select="current-group()[1]" mode="m:index-primary"> + <xsl:with-param name="scope" select="$scope"/> + <xsl:with-param name="role" select="$role"/> + <xsl:with-param name="type" select="$type"/> + <xsl:with-param name="lang" select="$lang"/> + </xsl:apply-templates> + </xsl:for-each-group> </dl> </div> </xsl:if> @@ -335,23 +337,11 @@ </xsl:call-template> </xsl:when> <xsl:otherwise> - <a> - <xsl:variable name="title"> - <xsl:choose> - <xsl:when test="§ion;/db:titleabbrev and $index.prefer.titleabbrev != 0"> - <xsl:apply-templates select="§ion;" mode="m:titleabbrev-markup"/> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="§ion;" mode="m:title-markup"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - - <xsl:attribute name="href"> - <xsl:value-of select="f:href(/,§ion;)"/> - </xsl:attribute> - - <xsl:value-of select="$title"/> <!-- text only --> + <xsl:variable name="tobject" + select="ancestor::*[db:info/db:title][1]"/> + <!-- FIXME: what about titleabbrev? --> + <a title="{$tobject/db:info/db:title}" href="{f:href(/,.)}"> + <xsl:value-of select="position()"/> </a> <xsl:if test="key('endofrange', @xml:id)[&scope;]"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |