xsl-list
[Top] [All Lists]

AW: [xsl] table formating

2011-01-26 08:33:55
Works !

Thank you !


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT-Entwickler 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 


-----Ursprüngliche Nachricht-----

Von: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com] 
Gesendet: Mittwoch, 26. Jänner 2011 15:20
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] table formating

On 26/01/2011 14:08, Michael Kay wrote:
Do a preprocessing pass to add an @index attribute to all cells.

Identity template plus

<xsl:template match="row">
<xsl:for-each-group select="cell" group-starting-with="cell[@index]">
<xsl:for-each select="current-group()">
<cell index="{current-group()[1]/@index + position() - 1}">
<xsl:copy-of select="child::node()"/>
</
</
</
</

Sorry, that's the answer to a slightly different question - but one 
that's often useful in this kind of situation.

For your problem I'd be inclined to use sibling recursion:

<xsl:template match="row">
<xsl:apply-templates select="cell[1]" mode="add-missing-cells">
<xsl:wirh-param name="present-in-output select="0"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="cell" mode="add-missing-cells" priority="1">
<xsl:with-param name="present-in-output" as="xs:integer"/>
<xsl:copy-of select="."/>
<xsl:apply-templates select="following-sibling::cell[1]" 
mode="add-missing-cells">
<xsl:with-param name="present-in-output select="$present-in-output+1"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="cell[@index]" mode="add-missing-cells" priority="2">
<xsl:wirh-param name="present-in-output" as="xs:integer"/>
<xsl:variable name="missing" select="@index - ($present-in-output + 1)" 
as="xs:integer"/>
<xsl:for-each select="1 to $missing"><cell/></xsl:for-each>
<xsl:copy-of select="."/>
<xsl:apply-templates select="following-sibling::cell[1]" 
mode="add-missing-cells">
<xsl:with-param name="present-in-output 
select="$present-in-output+$missing+1"/>
</xsl:apply-templates>
</xsl:template>

Michael Kay
Saxonica

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>