My goal is to transform an xml file to an html file, and style its contents as a table. However, I only want exactly four elements per row, and I can't seem to find a wayon how to achieve this.
members.xml:
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "/teammembers_imports.xsl"?>
<team>
<heading>TEST TEAM</heading>
<member>
<name>Max Mustermann</name>
<role>Product Owner</role>
</member>
<member>
<name>Max Mustermann 2</name>
<role>Product Owner</role>
</member>
<member>
<name>Max Mustermann 3</name>
<role>Product Owner</role>
</member>
<member>
<name>Max Mustermann 4</name>
<role>Product Owner</role>
</member>
<member>
<name>Max Mustermann 5</name>
<role>Product Owner</role>
</member>
</team>
teammembers_imports.xsl:
<?xml version = "1.0" encoding="UTF-8"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<table>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="member">
<td>
<xsl:value-of select="name"/>
</td>
</xsl:template>
</xsl:stylesheet>
Assuming you want a result that looks like:
you could do:
XSLT 1.0
Alternatively you could do:
but the result will not look the same for the last, incomplete, row.