[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: table creation with element repetition

Subject: Re: table creation with element repetition
From: Fantuzzi Alessandro <a.fantuzzi@xxxxxxxxxx>
Date: Tue, 04 May 2004 11:00:45 +0200
xsl row break
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() &lt;= 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() &lt;= 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.