0
我正在閱讀一本名爲ineasysteps的書,並且我遇到了有關XSL和XML的問題之一。爲XML/XSL選擇元素值
出於某種原因,我無法在瀏覽器中打開xml文檔。我相信我的代碼不正確,但請讓我知道我在這裏做錯了什麼。
謝謝你,代碼是下面貼:
這裏是XML文檔: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>
這裏是價值of.xsl文件:
<?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>
可能重複:** [XSLT在Web瀏覽器不工作(HTTP://計算器。 COM /問題/ 29941662/XSLT - 不工作,在-Web瀏覽器)** – kjhughes