I'm fairly new to XSLT and I am stuck with a problem where I have an Element with an unknown amount of children, and I need to display these children in a table such that there are 5-6 columns available to display the information.
If I'm given an XML file that looks like this:
<books>
<book>
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
</book>
<book>
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
</book>
<book>
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
</book>
<book>
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
</book>
<book>
<author>Thurman, Paula</author>
<title>Splish Splash</title>
</book>
<book>
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
</book>
<book>
<author>Kress, Peter</author>
<title>Paradox Lost</title>
</book>
<book>
<author>Crichton, Michael</author>
<title>Jurassic Park</title>
</book>
<book>
<author>Orwell, George</author>
<title>1984</title>
</book>
<book>
<author>Martin, George</author>
<title>A Song of Ice And Fire</title>
</book>
</books>
I would like to display these 10 books in a table consisting of two rows and five columns.
I've gotten this far:
<xsl:template match="books" mode="table">
<fo:table margin-left="auto" margin-right="auto">
<fo:table-body>
<fo:table-row table-layout="fixed">
<xsl:for-each select="skill">
<fo:table-cell border="1">
<fo:block font-weight="bold">
<xsl:value-of select="name"/>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
But all this will do is put every cell on the same row. I'm looking for a way to check if the loop has run a certain amount of times (5 or 6), and inserting a new row when that happens, but I don't know if that's something I can do in XSL.
Can anyone point me in the right direction?