Hello,
I'm working through a tutorial in the Deitel & Deitel book. I'm doing a for-each statement, but my values are not showing up. The only thing that is showing up is my thead info. I have pasted my two files below. Any advice would be greatly appreciated! Thanks in advance
Kelly
ex20_9.xml file
ex20_10.xsl file
I'm working through a tutorial in the Deitel & Deitel book. I'm doing a for-each statement, but my values are not showing up. The only thing that is showing up is my thead info. I have pasted my two files below. Any advice would be greatly appreciated! Thanks in advance
Kelly
ex20_9.xml file
Code:
<?xml version="1.0"?>
<?xml:stylesheet type = "text/xsl" href = "ex20_10.xsl"?>
<!--Kelly S. Brace: ksb8327-->
<!--Example 20_9.xml-->
<nutritionFacts>
<productName>Grandma Deitel's Cookies</productName>
<servingSize> 1 package</servingSize>
<nutrients>
<nutrient name = "calories">
<value>260</value>
</nutrient>
<nutrient name = "fatCalories">
<value>100</value>
</nutrient>
<nutrient name = "sodium">
<value>210 milligrams</value>
</nutrient>
<nutrient name = "cholesterol">
<value>5 milligrams</value>
</nutrient>
<nutrient name = "protein">
<value>5 grams</value>
</nutrient>
<nutrient name = "fat">
<value>11 grams</value>
</nutrient>
<nutrient name = "saturatedFat">
<value>2 grams</value>
</nutrient>
<nutrient name = "carbohydrates">
<value>36 grams</value>
</nutrient>
<nutrient name = "fiber">
<value>2 grams</value>
</nutrient>
<nutrient name = "sugar">
<value>5 grams</value>
</nutrient>
</nutrients>
</nutritionFacts>
Code:
<?xml version = "1.0"?>
<!--Kelly S. Brace: ksb8327-->
<xsl:stylesheet version = "1.0"
xmlns:xsl = "[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method = "html" omit-xml-declaration = "no"
doctype-system = "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[/URL]
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"/>
<xsl:template match = "/">
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>Nutritional Facts for Grandma Dietel's Cookies</title>
</head>
<body>
<table border = "1">
<thead>
<tr>
<th>Nutrient</th>
<th>Value</th>
</tr>
</thead>
<xsl:for-each select = "nutrients/nutrient">
<tr>
<td><xsl:value-of select = "@name"/></td>
<td><xsl:value-of select = "value"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>