[Home] [By Thread] [By Date] [Recent Entries]
Dear Nic,
Please have a look and see if you can use anything of the following. It's based on DocBook XSL roundtrip (wich is XSLT 1.0, therefore there are two named templates instead of functions, for historical reasons), but slightly improved. <!-- (w:tbl and w:tr translate to tgroup and row straightforwardly; not included here) --> <!-- w:vMerge without Attribute means: a cell that is occupied by virtue of a row spanning cell in the preceding row, and which should be suppressed in CALS: --> <xsl:template match="w:tc[not(w:tcPr/w:vMerge[count(@*) = 0])]"> <xsl:element name="entry"> <!-- Process any spans --> <xsl:call-template name="cell.span"/> <xsl:call-template name="cell.morerows"/> <!-- <xsl:call-template name="cell.style"/> --><!-- (you didn't ask for styles) --> <xsl:apply-templates /> </xsl:element> </xsl:template> <!-- recursively count preceding columns, including spans --> <xsl:function name="letex:colcount" as="xs:double" saxon:memo-function="yes"> <xsl:param name="count" as="xs:double"/> <xsl:param name="cell" as="node()"/> <xsl:choose> <xsl:when test="$cell/preceding-sibling::w:tc"> <xsl:variable name="span" select="if ($cell/preceding-sibling::w:tc[1]/w:tcPr/w:gridSpan/@w:val) then $cell/preceding-sibling::w:tc[1]/w:tcPr/w:gridSpan/@w:val else 1"/> <xsl:sequence select="letex:colcount($count + $span, $cell/preceding-sibling::w:tc[1])" /> </xsl:when> <xsl:otherwise> <xsl:sequence select="$count"/> </xsl:otherwise> </xsl:choose> </xsl:function>
<!-- The trickiest part: --> <xsl:template name="cell.morerows"> <xsl:if test="w:tcPr/w:vMerge/@w:val = 'restart'"> <xsl:variable name="counts" as="xs:integer*"> <xsl:choose> <xsl:when test="../following-sibling::w:tr[1]/w:tc[letex:colcount(1, .) = letex:colcount(1, current())]/w:tcPr/w:vMerge[count(@*) = 0]"> <xsl:for-each-group select="../following-sibling::w:tr/w:tc[letex:colcount(1, .) = letex:colcount(1, current())]" group-adjacent="if (w:tcPr/w:vMerge[count(@*) = 0]) then true() else false()"> <xsl:sequence select="count(current-group())"/> </xsl:for-each-group> </xsl:when> <xsl:otherwise> <!-- shouldn't happen, need to fix the code: --> <xsl:sequence select="24"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:attribute name="morerows" select="$counts[1]" /> <xsl:attribute name="style" select="'border-bottom: none;'" /> </xsl:if> </xsl:template> I should have taken care of the "otherwise return 24" above. But I'm staying sick at home, and all I could do is copy and paste this code that I once wrote. I'm unable to think about it right now. Hope this helps anyway. Gerrit On 23.03.2010 13:07, Nic Gibson wrote: Morning
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler
|

Cart



