RE: [xsl] Carlos Problem (II) how to show some results y some pla ces:

Subject: RE: [xsl] Carlos Problem (II) how to show some results y some pla ces:
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Fri, 10 May 2002 10:43:48 +0100
Carlos wrote:

>is a very good method but i need other thing; in the fist td 1 4 7
>in the second 2 5 8 in the tree elemnt 3 6 9
>can anybody help me please, i must to solve this problem in my hob, i am
>exasperated, i am working in this problem one week and i cannot solve.
>please help me
>i want to present in this form:
><td>1 4 7....</td><td>2 5 8....</td><td>3 6 9....</td>
>and i dont want:

Hello Carlos,

Let say you want 3 columns. That means:
in column 1 you want element 1 (1 mod 3 = 1) , 4 (4 mod 3 = 1), 7 (7 mod 3 =
In column 2: 2, 5, 8  (5 mod 3 = 2) etc.
In fact, it looks as if with x columns, for column c you want elements where
position() mod x = c.
in column 3: 3 mod 3 = 0: this is the exception.

The stylesheet below uses a for-each to get the first 3 elements and uses
them to generate a variable called $mod, which counts from 1 to the number
of columns desired (in this case, 3), but ensures that the last value is a
0. So it counts 1 to 3 like this: 1, 2, 0.

The second for-each goes through all the REGISTRO elements, and groups them
according to the scheme explained above.

It should be fairly easy to adapt this method as a mode in your existing
stylesheet. Good luck,
Tom Weissmann

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>

<xsl:stylesheet version='1.0'

	<xsl:template match='/'>
			<xsl:apply-templates select='/INMOBILIARIAS'>
				<xsl:with-param name ="colCount" select

<xsl:template match="INMOBILIARIAS">
	<xsl:param name="colCount" select="/.."/>  <!-- the number of
columns to span -->
		<tr>       <!-- it looks like you only want just one row -
maybe -->

			<xsl:for-each select="REGISTRO[position() &lt;=
			<!-- the first for-each - count 1 to $colCount -->
			<xsl:variable name='mod'>
					<!-- for the $colCount-th set, $mod
needs to be 0, not $colCount -->
					<xsl:when test='position() mod
$colCount = 0'>
select="../REGISTRO[position() mod $colCount = $mod]">

 XSL-List info and archive:

Current Thread