Replies: 2 comments 8 replies
|
It is a bit tricky, you have to do some math. Here is my data file: <data>
<image>1.jpg</image>
<image>2.jpg</image>
<image>3.jpg</image>
<image>4.jpg</image>
<image>5.jpg</image>
<image>6.jpg</image>
<image>7.jpg</image>
<image>8.jpg</image>
<image>9.jpg</image>
</data>and here is my layout file: <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Record element="data">
<PlaceObject>
<Table>
<Loop select="count(image) idiv 2" variable="i">
<Tr>
<Td>
<Image file="{image[ position() = ( $i - 1 ) * 2 + 1 ]}" width="3" />
</Td>
<Td>
<Image file="{image[ position() = ( $i - 1 ) * 2 + 2 ]}" width="3" />
</Td>
</Tr>
</Loop>
<Switch>
<Case test="sd:odd(count(image))">
<Tr>
<Td>
<Image file="{image[ position() = last() ]}" width="3" />
</Td>
<Td></Td>
</Tr>
</Case>
</Switch>
</Table>
</PlaceObject>
</Record>
</Layout>So every row has two table cells and I need to calculate which image should be displayed. I can select the image node from the data with To arrange the images, I create a loop with the number of rows (rounded down, that is idiv, integer division) For the 9 images, I have four iterations of the loop. So the first row should get image 1 and 2, second row get image 3 and 4 and so on. The current iteration number is stored in the variable The first thing is to subtract 1 from the row counter When I add 1 and 2 to each counter, I get The last row is to check if the counter is odd, so I add the last image. There are other calculations possible of course. |



I assume something like this might work: