From: Norman W. <nw...@us...> - 2005-10-16 19:16:33
|
Update of /cvsroot/docbook/xsl2/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1749/common Modified Files: labels.xsl normalize.xsl table.xsl Log Message: Yet more hacking Index: labels.xsl =================================================================== RCS file: /cvsroot/docbook/xsl2/common/labels.xsl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -U2 -r1.7 -r1.8 --- labels.xsl 10 Oct 2005 13:12:04 -0000 1.7 +++ labels.xsl 16 Oct 2005 19:16:20 -0000 1.8 @@ -136,6 +136,9 @@ <xsl:number from="db:part" count="db:chapter" format="1" level="any"/> </xsl:when> - <xsl:otherwise> + <xsl:when test="$label.from.part != 0 and ancestor::db:book"> <xsl:number from="db:book" count="db:chapter" format="1" level="any"/> + </xsl:when> + <xsl:otherwise> + <xsl:number count="db:chapter" format="1" level="any"/> </xsl:otherwise> </xsl:choose> Index: normalize.xsl =================================================================== RCS file: /cvsroot/docbook/xsl2/common/normalize.xsl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -U2 -r1.7 -r1.8 --- normalize.xsl 13 Oct 2005 13:35:35 -0000 1.7 +++ normalize.xsl 16 Oct 2005 19:16:21 -0000 1.8 @@ -419,8 +419,18 @@ and db:imageobject/db:imagedata[@format='linespecific']]" mode="m:normalize"> - <xsl:value-of select="unparsed-text(db:imageobject/db:imagedata/@fileref)"/> + <xsl:variable name="data" + select="(db:imageobject + /db:imagedata[@format='linespecific'])[1]"/> + <xsl:choose> + <xsl:when test="$data/@entityref"> + <xsl:value-of select="unparsed-text(unparsed-entity-uri($data/@entityref))"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="unparsed-text($data/@fileref)"/> + </xsl:otherwise> + </xsl:choose> </xsl:template> -<xsl:template match="db:textdata +<xsl:template match="db:textobject [parent::db:programlisting or parent::db:screen @@ -429,5 +439,12 @@ or parent::db:funcsynopsisinfo]" mode="m:normalize"> - <xsl:value-of select="unparsed-text(@fileref)"/> + <xsl:choose> + <xsl:when test="db:textdata/@entityref"> + <xsl:value-of select="unparsed-text(unparsed-entity-uri(db:textdata/@entityref))"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="unparsed-text(db:textdata/@fileref)"/> + </xsl:otherwise> + </xsl:choose> </xsl:template> Index: table.xsl =================================================================== RCS file: /cvsroot/docbook/xsl2/common/table.xsl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -U2 -r1.8 -r1.9 --- table.xsl 8 Oct 2005 20:23:04 -0000 1.8 +++ table.xsl 16 Oct 2005 19:16:21 -0000 1.9 @@ -106,4 +106,7 @@ <xsl:variable name="entry" select="."/> + <xsl:variable name="row" select="$entry/parent::db:row"/> + <xsl:variable name="container" select="(ancestor::db:tgroup + |ancestor::db:entrytbl)[last()]"/> <xsl:variable name="nextpos" select="f:skip-overhang($overhang, $prevpos+1)" @@ -115,6 +118,5 @@ <xsl:variable name="name" select="@namest"/> <xsl:variable name="colspec" - select="ancestor::db:tgroup[1] - /db:colspec[@colname=$name]"/> + select="$container/db:colspec[@colname=$name]"/> <xsl:value-of select="f:colspec-colnum($colspec)"/> </xsl:when> @@ -122,6 +124,5 @@ <xsl:variable name="name" select="@colname"/> <xsl:variable name="colspec" - select="ancestor::db:tgroup[1] - /db:colspec[@colname=$name]"/> + select="$container/db:colspec[@colname=$name]"/> <xsl:value-of select="f:colspec-colnum($colspec)"/> </xsl:when> @@ -129,6 +130,5 @@ <xsl:variable name="name" select="@spanname"/> <xsl:variable name="spanspec" - select="ancestor::db:tgroup[1] - /db:spanspec[@spanname=$name]"/> + select="$container/db:spanspec[@spanname=$name]"/> <xsl:value-of select="f:spanspec-colnum-start($spanspec)"/> @@ -145,6 +145,5 @@ <xsl:variable name="name" select="@nameend"/> <xsl:variable name="colspec" - select="ancestor::db:tgroup[1] - /db:colspec[@colname=$name]"/> + select="$container/db:colspec[@colname=$name]"/> <xsl:value-of select="f:colspec-colnum($colspec) - $pos + 1"/> @@ -153,6 +152,5 @@ <xsl:variable name="name" select="@spanname"/> <xsl:variable name="spanspec" - select="ancestor::db:tgroup[1] - /db:spanspec[@spanname=$name]"/> + select="$container/db:spanspec[@spanname=$name]"/> <xsl:value-of select="f:spanspec-colnum-end($spanspec) - $pos + 1"/> @@ -169,5 +167,10 @@ </xsl:when> <xsl:otherwise> - <ghost:empty ghost:colnum="{$col}" ghost:morerows="0"/> + <ghost:empty ghost:colnum="{$col}" ghost:morerows="0"> + <xsl:call-template name="inherit-table-attributes"> + <xsl:with-param name="colnum" select="."/> + <xsl:with-param name="row" select="$row"/> + </xsl:call-template> + </ghost:empty> </xsl:otherwise> </xsl:choose> @@ -199,4 +202,14 @@ </xsl:for-each> + <!-- + <xsl:message> + <xsl:value-of select="$pos"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="count(following-sibling::*)"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$container/@cols"/> + </xsl:message> + --> + <xsl:apply-templates select="(following-sibling::db:entry |following-sibling::db:entrytbl)[1]" @@ -205,4 +218,18 @@ <xsl:with-param name="prevpos" select="$pos + $width - 1"/> </xsl:apply-templates> + + <!-- pad the row with empties if necessary --> + <xsl:if test="not(following-sibling::db:entry|following-sibling::db:entrytbl)"> + <xsl:for-each select="for $col + in ($pos+1 to $container/@cols) + return $col"> + <ghost:empty ghost:colnum="{.}" ghost:morerows="0"> + <xsl:call-template name="inherit-table-attributes"> + <xsl:with-param name="colnum" select="."/> + <xsl:with-param name="row" select="$row"/> + </xsl:call-template> + </ghost:empty> + </xsl:for-each> + </xsl:if> </xsl:template> @@ -301,4 +328,12 @@ </listitem> </varlistentry> +<varlistentry><term>row</term> +<listitem> +<para>The row containing the cell, defaults to the parent of the entry. +This parameter exists independent of the entry because when the entry is +an empty column (for example, at the end of a short row), the entry will +be an integer and won't have a parent.</para> +</listitem> +</varlistentry> </variablelist> </refparameter> @@ -312,4 +347,5 @@ <xsl:param name="entry" select="."/> <xsl:param name="colnum" required="yes"/> + <xsl:param name="row" select="$entry/parent::db:row"/> <!-- the table attributes come from: @@ -325,5 +361,5 @@ in that order --> - <xsl:variable name="tgroup" select="$entry/ancestor::db:tgroup[1]"/> + <xsl:variable name="tgroup" select="$row/ancestor::db:tgroup[1]"/> <xsl:variable name="table" select="$tgroup/parent::*"/> <xsl:variable name="spanspec" @@ -331,14 +367,27 @@ <xsl:variable name="elements" as="element()*"> - <xsl:sequence select="($entry, - $entry/parent::db:row, - $tgroup, - $tgroup/parent::*, - $spanspec, - $tgroup/db:colspec[@colname=$spanspec/@namest], - $tgroup/db:colspec[@colname=$entry/@namest], - f:find-colspec-by-colnum($tgroup, $colnum))"/> + <xsl:choose> + <xsl:when test="$entry instance of element()"> + <xsl:sequence select="($entry, + $row, + $tgroup, + $tgroup/parent::*, + $spanspec, + $tgroup/db:colspec[@colname=$spanspec/@namest], + $tgroup/db:colspec[@colname=$entry/@namest], + f:find-colspec-by-colnum($tgroup, $colnum))"/> + </xsl:when> + <xsl:otherwise> + <xsl:sequence select="($row, + $tgroup, + $tgroup/parent::*, + f:find-colspec-by-colnum($tgroup, $colnum))"/> + </xsl:otherwise> + </xsl:choose> </xsl:variable> + <xsl:variable name="colspec" + select="f:find-colspec-by-colnum($tgroup, $colnum)"/> + <xsl:for-each select="('rowsep', 'colsep', 'align', 'valign', @@ -346,4 +395,18 @@ <xsl:variable name="attr" select="QName('', .)"/> + <xsl:variable name="value"> + <xsl:choose> + <xsl:when test="f:find-element-by-attribute($elements, $attr)"> + <xsl:value-of select="f:find-element-by-attribute($elements, $attr) + /@*[node-name() = $attr]"/> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$attr=QName('','rowsep') or $attr=QName('','colsep')"> + <xsl:value-of select="1"/> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:choose> <xsl:when test="f:find-element-by-attribute($elements, $attr)"> @@ -437,8 +500,8 @@ <u:param name="colgroup" as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="3.5*"/> - <col colwidth="2*"/> + <col width="3.5*"/> + <col width="2*"/> <col/> - <col colwidth="1*"/> + <col width="1*"/> </colgroup> </u:param> @@ -446,8 +509,8 @@ <u:result as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="47%"/> - <col colwidth="27%"/> - <col colwidth="13%"/> - <col colwidth="13%"/> + <col width="47%"/> + <col width="27%"/> + <col width="13%"/> + <col width="13%"/> </colgroup> </u:result> @@ -457,8 +520,8 @@ <u:param name="colgroup" as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="2in"/> - <col colwidth="3in"/> - <col colwidth="8pt"/> - <col colwidth="1in"/> + <col width="2in"/> + <col width="3in"/> + <col width="8pt"/> + <col width="1in"/> </colgroup> </u:param> @@ -466,8 +529,8 @@ <u:result as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="192"/> - <col colwidth="288"/> - <col colwidth="10"/> - <col colwidth="96"/> + <col width="192"/> + <col width="288"/> + <col width="10"/> + <col width="96"/> </colgroup> </u:result> @@ -477,8 +540,8 @@ <u:param name="colgroup" as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="3.5*+2in" colname="foo"/> - <col colwidth="2*"/> + <col width="3.5*+2in" colname="foo"/> + <col width="2*"/> <col/> - <col colwidth="1in" align="right"/> + <col width="1in" align="right"/> </colgroup> </u:param> @@ -486,8 +549,8 @@ <u:result as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="502" colname="foo"/> - <col colwidth="177"/> - <col colwidth="89"/> - <col colwidth="96" align="right"/> + <col width="502" colname="foo"/> + <col width="177"/> + <col width="89"/> + <col width="96" align="right"/> </colgroup> </u:result> @@ -497,8 +560,8 @@ <u:param name="colgroup" as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="3.5*+2in" colname="foo"/> - <col colwidth="2*"/> + <col width="3.5*+2in" colname="foo"/> + <col width="2*"/> <col/> - <col colwidth="1in" align="right"/> + <col width="1in" align="right"/> </colgroup> </u:param> @@ -506,8 +569,8 @@ <u:result as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="58.12%" colname="foo"/> - <col colwidth="20.51%"/> - <col colwidth="10.26%"/> - <col colwidth="11.11%" align="right"/> + <col width="58.12%" colname="foo"/> + <col width="20.51%"/> + <col width="10.26%"/> + <col width="11.11%" align="right"/> </colgroup> </u:result> @@ -517,16 +580,35 @@ <u:param name="colgroup" as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="3.5*+2in" colname="foo"/> - <col colwidth="2*"/> + <col width="3.5*+2in" colname="foo"/> + <col width="2*"/> <col/> - <col colwidth="1in" align="right"/> + <col width="1in" align="right"/> </colgroup> </u:param> <u:result as="element()"> <colgroup xmlns="http://www.w3.org/1999/xhtml"> - <col colwidth="5.23in" colname="foo"/> - <col colwidth="1.85in"/> - <col colwidth="0.92in"/> - <col colwidth="1.00in" align="right"/> + <col width="5.23in" colname="foo"/> + <col width="1.85in"/> + <col width="0.92in"/> + <col width="1.00in" align="right"/> + </colgroup> + </u:result> + </u:test> + <u:test> + <u:param name="table-width">100%</u:param> + <u:param name="colgroup" as="element()"> + <colgroup xmlns="http://www.w3.org/1999/xhtml"> + <col width="1in"/> + <col width="1*"/> + <col width="5*"/> + <col width="1*+0.5in"/> + </colgroup> + </u:param> + <u:result as="element()"> + <colgroup xmlns="http://www.w3.org/1999/xhtml"> + <col width="5.23in" colname="foo"/> + <col width="1.85in"/> + <col width="0.92in"/> + <col width="1.00in" align="right"/> </colgroup> </u:result> @@ -541,27 +623,27 @@ <xsl:variable name="parsedcols" as="element()*"> - <xsl:for-each select="$colgroup/h:col"> + <xsl:for-each select="$colgroup/*"> <xsl:choose> - <xsl:when test="not(@colwidth)"> + <xsl:when test="not(@width)"> <col ghost:rel="1" ghost:abs="0"> <xsl:copy-of select="@*"/> </col> </xsl:when> - <xsl:when test="contains(@colwidth, '*')"> - <col ghost:rel="{substring-before(@colwidth, '*')}" - ghost:abs="{if (substring-after(@colwidth, '*') = '') + <xsl:when test="contains(@width, '*')"> + <col ghost:rel="{substring-before(@width, '*')}" + ghost:abs="{if (substring-after(@width, '*') = '') then 0 - else f:convert-length(substring-after(@colwidth, '*'))}"> + else f:convert-length(substring-after(@width, '*'))}"> <xsl:copy-of select="@*"/> </col> </xsl:when> - <xsl:when test="matches(@colwidth, '^\d+$')"> + <xsl:when test="matches(@width, '^\d+$')"> <col ghost:rel="0" - ghost:abs="{f:convert-length(concat(@colwidth,'px'))}"> + ghost:abs="{f:convert-length(concat(@width,'px'))}"> <xsl:copy-of select="@*"/> </col> </xsl:when> <xsl:otherwise> - <col ghost:rel="0" ghost:abs="{f:convert-length(@colwidth)}"> + <col ghost:rel="0" ghost:abs="{f:convert-length(@width)}"> <xsl:copy-of select="@*"/> </col> @@ -577,5 +659,5 @@ <col> <xsl:copy-of select="@*[namespace-uri(.) != 'http://docbook.org/ns/docbook/ephemeral']"/> - <xsl:attribute name="colwidth"> + <xsl:attribute name="width"> <xsl:choose> <xsl:when test="$abspixels = 0"> @@ -597,5 +679,5 @@ <col> <xsl:copy-of select="@*[namespace-uri(.) != 'http://docbook.org/ns/docbook/ephemeral']"/> - <xsl:attribute name="colwidth"> + <xsl:attribute name="width"> <xsl:value-of select="round(@ghost:rel div $relTotal * 100)"/> <xsl:text>%</xsl:text> @@ -608,9 +690,23 @@ <xsl:variable name="pixelwidth" select="if (contains($table-width, '%')) - then $nominal-table-width + then f:convert-length($nominal-table-width) else f:convert-length($table-width)"/> <xsl:variable name="convcols" as="element()*"> <xsl:for-each select="$parsedcols"> + <!-- + <xsl:message> + <xsl:value-of select="position()"/> + <xsl:text>=</xsl:text> + <xsl:value-of select="@ghost:rel"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="@ghost:abs"/> + <xsl:text>; </xsl:text> + <xsl:value-of select="$relTotal"/> + <xsl:text>; </xsl:text> + <xsl:value-of select="$pixelwidth"/> + </xsl:message> + --> + <col> <xsl:copy-of select="@*"/> @@ -626,5 +722,9 @@ <xsl:if test="$absTotal > $pixelwidth"> <xsl:message> - <xsl:text>Warning: table is wider than specified width.</xsl:text> + <xsl:text>Warning: table is wider than specified width. (</xsl:text> + <xsl:value-of select="$absTotal"/> + <xsl:text> vs. </xsl:text> + <xsl:value-of select="$pixelwidth"/> + <xsl:text>)</xsl:text> </xsl:message> </xsl:if> @@ -636,5 +736,5 @@ <xsl:copy-of select="@*[namespace-uri(.) != 'http://docbook.org/ns/docbook/ephemeral']"/> - <xsl:attribute name="colwidth"> + <xsl:attribute name="width"> <xsl:value-of select="format-number(@ghost:rel div $absTotal * 100, '0.00')"/> @@ -648,5 +748,5 @@ <col> <xsl:copy-of select="@*[namespace-uri(.) != 'http://docbook.org/ns/docbook/ephemeral']"/> - <xsl:attribute name="colwidth"> + <xsl:attribute name="width"> <xsl:choose> <xsl:when test="$abspixels = 0"> @@ -937,5 +1037,7 @@ <xsl:choose> - <xsl:when test="$pos > count($overhang)">0</xsl:when> + <xsl:when test="$pos > count($overhang)"> + <xsl:value-of select="$pos"/> + </xsl:when> <xsl:otherwise> <xsl:value-of select="if ($overhang[$pos] = 0) |