Il ven, 2004-04-30 alle 16:45, David Carlisle ha scritto:
your code is fine, but now I have another problem to solve, I should
insert a page break after a certain number of rows, let's say 6.
the point is that I don't know how to count loops in a for-each block
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="products_to_print">
<fo:table-body>
<xsl:apply-templates select="product[1]"/>
</fo:table-body>
</xsl:template>
<xsl:template match="product">
<xsl:param name="x" select="/.."/>
<xsl:variable name="y">
<fo:table-cell><xsl:apply-templates/></fo:table-cell>
</xsl:variable>
<xsl:variable name="c" select="@copies"/>
<xsl:choose>
<xsl:when test="not($x)">
<xsl:for-each select="(//*)[position() <= floor($c div 2)]">
<fo:table-row>
<xsl:copy-of select="$y"/>
<xsl:copy-of select="$y"/>
</fo:table-row>
<!-- break condition -->
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<fo:table-row>
<xsl:copy-of select="$x"/>
<xsl:copy-of select="$y"/>
</fo:table-row>
<!-- break condition -->
<xsl:for-each select="(//*)[position() <= floor(($c - 1) div 2)]">
<fo:table-row>
<xsl:copy-of select="$y"/>
<xsl:copy-of select="$y"/>
</fo:table-row>
<!-- break condition -->
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="(not($x) and @copies mod 2 = 1) or ($x and @copies mod 2 =
0)">
<xsl:apply-templates select="following-sibling::product[1]">
<xsl:with-param name="x" select="$y"/>
</xsl:apply-templates>
<xsl:if test="not(following-sibling::product)">
<fo:table-row>
<xsl:copy-of select="$y"/>
<fo:table-cell/>
</fo:table-row>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="following-sibling::product[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="description">
<fo:block><xsl:apply-templates/></fo:block>
</xsl:template>
</xsl:stylesheet>
thank in advance,
ALESSANDRO