Click to See Complete Forum and Search --> : xsl:for-each


DonMArtin
07-27-2003, 05:07 PM
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="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:

DonMArtin
07-27-2003, 05:24 PM
now I finally stripped it to the bones---negative

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="library">
<html>
<body>
<xsl:for-each select="book">
<xsl:for-each select="theme">
<xsl:value-of select="theme"/>blabla<br/>
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

I can see the correct number of blabla's but NO theme's value

DonMArtin
07-27-2003, 05:34 PM
simple mistake...I found it:

<xsl:value of select="."/>

Thanks anyway

:p

DonMArtin
07-27-2003, 05:36 PM
<xsl:value-of select="."/>