xsl:for-each

admin

Administrator
Staff member
Hi Pros,

just starting xml. I'm stuck in one of my first simple codes. I need to use two xsl:for-each one within the other. I think it should work although it's not valid. I can't see why it would not show the 'theme's value! It generates the tables but leaves them empty. Are there any restrictions or rules to meet concerning two xsl:for-each?
Here are the codes:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href=http://www.webdeveloper.com/forum/archive/index.php/"math1.xsl" type="text/xsl"?>
<library>
<book>
<theme>A</theme>
<theme>B</theme>
<theme>C</theme>
</book>
<book>
<theme>D</theme>
<theme>F</theme>
</book>
</library>
-----------------------
math1.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="library">
<html>
<head>
<title>library</title>
</head>
<body>
<table border="1">
<tr>
<td>library</td>
</tr>
<tr>
<td>
<xsl:for-each select="book">
<table border="2" bgcolor="blue">
<xsl:for-each select="theme">
<tr>
<td>
<xsl:value-of select="theme"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>:mad:
 
Back
Top