I'm going through a book called ineasysteps, and I am stuck on one of the questions about XSL and XML.
For some reason, I am not able to open up the xml document in the browser. I believe my code is incorrect, but please let me know what I'm doing wrong here.
Thank You, Code is posted Below:
Here is the XML Document: cars.xml
<?xml version = "1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 99. -->
<?xml-stylesheet type = "text/xsl" href = "value-of.xsl" ?>
<car:doc
xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation =
"http://www.ineasysteps.com/xsd cars.xsd"
xmlns:car = "http://www.ineasysteps.com/xsd" >
<car:item id = "corvette">
<car:make>Chevrolet</car:make>
<car:model>Corvette</car:model>
<car:ltr>6.0</car:ltr>
<car:cyl>8</car:cyl>
<car:hp>400</car:hp>
<car:price>53000</car:price>
</car:item>
<car:item id = "viper">
<car:make>Dodge</car:make>
<car:model>Viper</car:model>
<car:ltr>8.3</car:ltr>
<car:cyl>10</car:cyl>
<car:hp>510</car:hp>
<car:price>85000</car:price>
</car:item>
<car:item id = "solstice">
<car:make>Pontiac</car:make>
<car:model>Solstice</car:model>
<car:ltr>2.4</car:ltr>
<car:cyl>4</car:cyl>
<car:hp>177</car:hp>
<car:price>22000</car:price>
</car:item>
Here is the value-of.xsl document:
<?xml version = "1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 100. -->
<xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:c = "http://www.ineasysteps.com/xsd" >
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:template match = "/">
<html> <head><title>XSL Output</title> </head> <body>
<ul style = "list-style-type:square;color:red">
<li> <xsl:value-of select = "car:item/car:make" /> </li>
<li> <xsl:value-of select = "car:item/car:model" /> </li>
<li> <xsl:value-of select = "car:item/car:ltr" /> Liters </li>
<li> <xsl:value-of select = "car:item/car:cyl" /> Cylinders</li>
<li> <xsl:value-of select = "car:item/car:hp" /> Horsepower</li>
<li> <xsl:value-of select = "car:item/car:price" /> </li>
</ul>
</body> </html>
</xsl:template>
</xsl:stylesheet>