hello,
i'm trying to write a template to convert a html table to pdf
the problem is that the table-fo structure need the table columns to be declared beforehand.
so i want to find the line of the table with the maximum number of cells (because of eventual colspan columns) and transform it in columns declaration.
my template look like this :
<xsl:template match="table">
<fo:table>
<xsl:if test="@cellspacing!=''">
<xsl:attribute name="border-spacing"><xsl:value-of select="@cellspacing"/></xsl:attribute>
</xsl:if>
<xsl:if test="@cellpadding!=''">
<xsl:attribute name="padding"><xsl:value-of select="@cellpadding"/></xsl:attribute>
</xsl:if>
<xsl:if test="@width!=''">
<xsl:attribute name="inline-progression-dimension"><xsl:value-of select="@width"/></xsl:attribute>
<xsl:attribute name="table-layout">fixed</xsl:attribute>
</xsl:if>
<xsl:variable name="nbCols">
<xsl:for-each select="tr">
<nbCol><xsl:value-of select="count(td)"/></nbCol>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="maxCol">
<xsl:call-template name="math:max">
<xsl:with-param name="nodes" select="$nbCols" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="positions">
<xsl:for-each select="tr[count(td)=$maxCol]">
<posTd value="{position()}"/>
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="tr[position()=$positions/posTd[position()=1]]/@value" mode="table-columns"/-->
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="tr" mode="table-columns">
<xsl:for-each select="td">
<fo:table-column column-number="{position()}">
<xsl:if test="@width!=''">
<xsl:attribute name="column-width"><xsl:value-of select="@width"/></xsl:attribute>
</xsl:if>
</fo:table-column>
</xsl:for-each>
</xsl:template>
<!--template from exslt.org-->
<xsl:template name="math:max">
<xsl:param name="nodes" select="/.." />
<xsl:choose>
<xsl:when test="not($nodes)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$nodes">
<xsl:sort data-type="number" order="descending" /> <xsl:if test="position() = 1">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>The issue is that apparently the max template can't be applied to a tree fragment. Does anyone have an idea of a workaround ?
thanks for any help
Marc
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
