Subject: Re: Looping in XSLT(old question, but maybe new problem)
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 23 Jun 2003 20:03:35 -0600 (MDT)
|
Liu Shuai wrote:
> Hi, all
>
> I am trying to write a template that will generate a table based on a xml
> file and right now I don't have any
> clue how to do it.
>
> If I have a source file looks like this
>
> <foo>
> <bar id='1'>
> <someElement>a</someElement>
> </bar>
> <bar id='2'>
> <someElement>b</someElement>
> </bar>
> <bar id='3'>
> <someElement>c</someElement>
> </bar>
> <bar id='4'>
> <someElement>d</someElement>
> </bar>
> <bar id='5'>
> <someElement>e</someElement>
> </bar>
> ...
> </foo>
>
> Can I write a style sheet that will transform the source file above to a
> html table like this?
>
> <table>
> <tr>
> <td>a</td>
> <td>b</td>
> <td>c</td>
> </tr>
> <tr>
> <td>d</td>
> <td>e</td>
> <td> </td>
> </tr>
> ...
> </table>
>
> Basicly, I want to generate N columns per row but I don't know how many
> "bar"s I have in the source file.
Select all bar elements for processing.
In the template that matches a bar element, if position() returns
a value that when divided by 3 has a remainder of 1, generate a table row
element. Inside that element, create cells for the current node and its
first two following siblings.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|