The xsl:for-each element processes all the nodes in the same way, one after the other.
File: Data.xml
<?xml version="1.0"?>
<employees>
<animal>
<name language="English">T1</name>
<name language="Latin">T2</name>
<projects>
<project>project1</project>
</projects>
</animal>
</employees>
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="animal">
<paragraph align="center">
<br />
<font size="+3">
<xsl:apply-templates select="name" />
</font>
</paragraph>
<table width="100%" border="2">
<tr>
<td>Subspecies</td>
<td>Region</td>
<td>Number</td>
<td>As Of</td>
</tr>
<xsl:for-each select="subspecies">
<tr>
<td>
<xsl:apply-templates select="name" />
</td>
<td>
<xsl:value-of select="region" />
</td>
<td>
<xsl:value-of select="population" />
</td>
<td>
<xsl:value-of select="population/@year" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<paragraph align="center"><br/><font size="+3">T1T2</font></paragraph><table width="100%" border="2"><tr><td>Subspecies</th><td>Region</th><td>Number</th><td>As Of</th></tr></table>
|